Using Python's built-in defaultdict we can easily define a tree data structure:
def tree(): return defaultdict(tree)That's it!
| # 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) |
| 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] |
Using Python's built-in defaultdict we can easily define a tree data structure:
def tree(): return defaultdict(tree)That's it!
| // 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: |
| #include <stdlib.h> | |
| #include <assert.h> | |
| typedef struct deque | |
| { | |
| int left, right; | |
| int size; | |
| void **data; | |
| } deque; |
| //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 |
| // 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. |
| OK, Let's begin. Hello, Everybody. | |
| My name is Narihiro Nakamura. | |
| Today, I'm talking about "Parallel worlds of CRuby's GC". | |
| I'm very happy now, because I'm meeting attendee in rubyconf. | |
| And, one of my dreams is to talk in rubyconf. | |
| So, I'm very happy and exciting. | |
| Today is my first presentation in English. | |
| My English is not good. |
| #!/usr/bin/env python | |
| ''' | |
| This is an attempt of an alternative to | |
| http://code.activestate.com/recipes/577068-floating-point-range/ | |
| but generating the expected floating-point elements in the range, | |
| avoiding floating-point arithmetic problems. | |
| Currently it works rather well, although without the original | |
| validation steps (which seem to be overengineering to me), considering |
| DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE | |
| Version 2, December 2004 | |
| Copyright (C) 2011 Mathieu 'p01' Henri - http://www.p01.org/releases/ | |
| Everyone is permitted to copy and distribute verbatim or modified | |
| copies of this license document, and changing it is allowed as long | |
| as the name is changed. | |
| DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE |