Using Python's built-in defaultdict we can easily define a tree data structure:
def tree(): return defaultdict(tree)That's it!
| const lines = [ | |
| 'I am a string', | |
| 'I am not a string', | |
| 'Lies', | |
| 'You got me', | |
| ]; | |
| function printLines(callback: () => void) { | |
| lines.forEach((line, i) => console.log(`Line ${i}: ${line}`)); | |
| callback(); |
| def __iter__(self): | |
| for attr, value in self.__dict__.iteritems(): | |
| yield (attr, value) |
Using Python's built-in defaultdict we can easily define a tree data structure:
def tree(): return defaultdict(tree)That's it!
| groups = dict(list(gb)) |
| c1 c2 | |
| 0 3 10 | |
| 4 2 100 | |
| 1 2 30 | |
| 3 2 15 | |
| 2 1 20 |
| from xml.dom.minidom import parse, parseString | |
| import urllib2 | |
| # note - i convert it back into xml to pretty print it | |
| print parse(urllib2.urlopen("http://search.twitter.com/search.atom?&q=python")).toprettyxml(encoding="utf-8") |
| df['x'].str.lower() |
| du -hs /path/to/directory |
| npm ls |
| df[df['A'].isin([3, 6])] |