Groups
Groups
Sign in
Groups
Groups
Python Ireland
Conversations
About
Send feedback
Help
dictionary setdefault
5 views
Skip to first unread message
Sean O'Donnell
unread,
Mar 11, 2009, 10:21:43 PM
3/11/09
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Python Ireland
A nice recipe using the idioms discussed tonight
http://code.activestate.com/recipes/66516/
Michael Twomey
unread,
Mar 12, 2009, 3:52:07 AM
3/12/09
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to python...@googlegroups.com
Also, the defaultdict class (in python 2.5 onwards) lets you specify a
factory function instead of passing in the default:
http://docs.python.org/library/collections.html#collections.defaultdict
This is particularly useful for cases where the default value takes a
little while to construct or for shaving a few more lines off your
code.
(In python 2.6 defaultdict is right beside my new favourite class,
namedtuple:
http://docs.python.org/library/collections.html#collections.namedtuple
)
mick
Tim Kersten
unread,
Mar 12, 2009, 4:34:07 AM
3/12/09
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to python...@googlegroups.com
Sweeeeet namedtuples! :-) I like.
Reply all
Reply to author
Forward
0 new messages