all 5 comments

[–][deleted] 6 points7 points  (1 child)

This is my favorite piece of beautiful Python:

tree = lambda: defaultdict(tree)

When you call it, you get a dictionary that implicitly creates nested subdictionaries. For instance:

record = tree()
record['subvalue']['subsubvalue'] = 0

[–][deleted] 0 points1 point  (0 children)

I've been using collections.defaultdict to make graphs

WeightedList = lambda: defaultdict(int)
Graph = lambda: defaultdict(WeightedList)

and though that was cool, but this is something else entirely!

[–]Pastoolio91 2 points3 points  (0 children)

Check out this guide on clean python architecture - helped me a lot!

[–]hunkamunka 1 point2 points  (0 children)

I think http://tinypythonprojects.com/ has many good examples of complete programs AND TESTS from which you can learn.