October 2010
2 posts
1 tag
“Programs must be written for people to read, and only incidentally for machines...”
– H. Abelson and G. Sussman
Oct 11th
1 note
4 tags
Named Tuples
Named Tuples are awesome. They allow a coder to create very ad-hoc data structures while carrying enough identity information in the structure to treat them like types. Here I create a Person type out of a named tuple. >>> from collections import namedtuple >>> Person = namedtuple('Person', 'first_name last_name user_id') >>> p = Person('James', 'Dennis',...
Oct 9th