[Python-Dev] collections module (original) (raw)

Skip Montanaro 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.

Thx.

>> 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()

or

Alex> collection.each(lambda x: x.turn())

In LYMB (using Python syntax) it would have been something more like

all_actors.look_at(active_camera.position())

Hard to get any clearer than that. ;-)

It's pretty easily done with getattr.

Skip



More information about the Python-Dev mailing list