Skip to content

Instantly share code, notes, and snippets.

@grzes
grzes / dotexpandeddict.py
Last active September 17, 2020 08:26
Django's legacy DotExpendedDict
class DotExpandedDict(dict):
"""
A special dictionary constructor that takes a dictionary in which the keys
may contain dots to specify inner dictionaries. It's confusing, but this
example should make sense.
>>> d = DotExpandedDict({'person.1.firstname': ['Simon'], \
'person.1.lastname': ['Willison'], \
'person.2.firstname': ['Adrian'], \
'person.2.lastname': ['Holovaty']})
@grzes
grzes / encode.py
Created November 4, 2011 20:47
My python version of the Java vs C study test program.
"""
My solution to the Java-vs-C and later lisp-vs-java studies problem.
Test files and problem description: http://www.flownet.com/ron/papers/lisp-java/
33 lines of non whitespace non comment code, Took about 3 hours.
run:
$ python encode.py dictionary.txt input.txt
"""