Using Python's built-in defaultdict we can easily define a tree data structure:
def tree(): return defaultdict(tree)That's it!
| #Newbie programmer | |
| def factorial(x): | |
| if x == 0: | |
| return 1 | |
| else: | |
| return x * factorial(x - 1) | |
| print factorial(6) | |
| #First year programmer, studied Pascal |
| /*global ko, Chart */ | |
| (function(ko, Chart) { | |
| ko.bindingHandlers.chartType = { | |
| init: function(element, valueAccessor, allBindings, viewModel, bindingContext) { | |
| if (!allBindings.has('chartData')) { | |
| throw Error('chartType must be used in conjunction with chartData and (optionally) chartOptions'); | |
| } | |
| }, |
| from geventwebsocket.handler import WebSocketHandler | |
| from gevent.pywsgi import WSGIServer | |
| from flask import Flask, request, render_template | |
| app = Flask(__name__) | |
| @app.route('/') | |
| def index(): | |
| return render_template('index.html') |
Using Python's built-in defaultdict we can easily define a tree data structure:
def tree(): return defaultdict(tree)That's it!