Using Python's built-in defaultdict we can easily define a tree data structure:
def tree(): return defaultdict(tree)That's it!
| // Here is a proposal for minimalist JavaScript classes, humbly offered. | |
| // There are (at least) two different directions in which classes can be steered. | |
| // If we go for a wholly new semantics and implementation, then fancier classical | |
| // inheritance can be supported with parallel prototype chains for true inheritance | |
| // of properties at both the class and instance level. | |
| // If however, we keep current JavaScript prototype semantics, and add a form that | |
| // can desugar to ES3, things must necessarily stay simpler. This is the direction | |
| // I'm assuming here. |
| //work in progress | |
| // A response to jashkenas's fine proposal for minimalist JavaScript classes. | |
| // and BrendanEich's Rich Corinthian Leather alternative proposal | |
| //intro and justifications still to come | |
| // Harmony always stipulated classes as sugar, so indeed we are keeping current | |
| // JavaScript prototype semantics, and classes would only add a syntactic form | |
| // that can desugar to ES5. This is mostly the same assumption that Jeremy |
| #include <stdlib.h> | |
| #include <assert.h> | |
| typedef struct deque | |
| { | |
| int left, right; | |
| int size; | |
| void **data; | |
| } deque; |
| // by Dmitry Soshnikov <[email protected]> | |
| // on "noSuchMethod" hook via proxies | |
| // written on December 15, 2011 | |
| // Below is tl;dr | |
| // but if you want really never-ending tl;dr, try this | |
| // original old thread from 2010 on es-discuss: | |
| // https://mail.mozilla.org/pipermail/es-discuss/2010-October/011929.html | |
| // Small disclaimer and note: |
Using Python's built-in defaultdict we can easily define a tree data structure:
def tree(): return defaultdict(tree)That's it!
| class Reader: | |
| def __init__(self, form): | |
| self.form = form | |
| self.index = 0 | |
| def seek_char(self): | |
| if self.index >= len(self.form): | |
| return None | |
| return self.form[self.index] |
| # list_detail.object_list replacement with all the things I need | |
| def object_list(request, queryset, extra_context=None, | |
| template_name='', paginate_by=None): | |
| class ObjectList(ListView): | |
| def post(self, request, *args, **kwargs): | |
| return self.get(request, *args, **kwargs) | |
| def get_context_data(self, **kwargs): | |
| c = super(ObjectList, self).get_context_data(**kwargs) |
| # Search for statistic messages from the Python trakcer robot in | |
| # python-dev archives and plot the result. | |
| # | |
| # $ python-traker-stats.py collect | |
| # | |
| # Collects statistics from the mailing list and saves to | |
| # python-tracker-stats.json | |
| # | |
| # $ python-tracker-stats.py plot | |
| # |
| def _simple_processor(processor, ext_private, ext_public): | |
| if not request.path.endswith(ext_public): | |
| return | |
| public_file = request.path[len(config.app.static_url_path) + 1:] | |
| public_file_path = os.path.join(config.app.static_folder, public_file) | |
| private_file_path = public_file_path[:-len(ext_public)] + ext_private | |
| # File does not exist in app static - check blueprints. | |
| if not os.path.isfile(private_file_path): | |
| for blueprint_name, blueprint in config.app.blueprints.iteritems(): | |
| if request.path.startswith(blueprint.static_url_path): |
| /* Any copyright is dedicated to the Public Domain. | |
| * http://creativecommons.org/publicdomain/zero/1.0/ */ | |
| Components.utils.import("resource:///modules/devtools/gcli.jsm"); | |
| var helloCommandSpec = { | |
| name: 'hello', | |
| description: 'Show a message', | |
| params: [ | |
| { |