Advertisement
rfmonk

collections_defaultdict.py

Jan 9th, 2014
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.21 KB | None | 0 0
  1. #!/usr/bin/env python
  2.  
  3.  
  4. import collections
  5.  
  6.  
  7. def default_factory():
  8.     return 'default value'
  9.  
  10. d = collections.defaultdict(default_factory, foo='bar')
  11. print 'd:', d
  12. print 'foo =>', d['foo']
  13. print 'bar =>', d['bar']
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement