[Python-Dev] collections module
skip at pobox.com
Fri Jan 9 11:17:28 EST 2004
>> I'm neither a Smalltalk, C++ or Objective C programmer. How is a bag
>> different from a set?
Alex> In a bag, or multiset, a certain item can be in the collection a
Alex> given _number_ of times, rather than just "either being there or
Alex> not" as in a set.
>> Oddly enough, although we used collections heavily, I never really
>> missed that functionality in Python. I implemented it once or twice,
>> but never used it much. Different style of programming I guess.
Alex> for item in collection: item.turn()
Alex> collection.each(lambda x: x.turn())
In LYMB (using Python syntax) it would have been something more like
Hard to get any clearer than that. ;-)
It's pretty easily done with __getattr__.
More information about the Python-Dev