2.2, iterators, list comprehensions, get/set, & win32all

Tim Peters tim.one at home.com
Thu Oct 25 23:55:20 EDT 2001


[Mike Dean]
> I'm wanting to do some experimenting with Python 2.2, and I have a
> couple of questions....
>
> First, do list comprehensions use the new iterator/generator protocol in
> their for loop, or do they use the old method of sequence iteration?

All 2.2 for-loops (whether or not in list comprehensions) use the 2.2
iterator protocol; this is 100% backward-compatible with 2.1's __getitem__
protocol.

> Also, it seems like I remember seeing something about
> __get_spam__/__set_spam__ (or something like that) magic methods in
> Python 2.2 - am I correct that such animals exist, and if so, where are
> they documented (specifically in the 2.2b1 manual)?

Lots of the new stuff isn't even mentioned in the docs yet.  Per-attribute
getter/setter/deleters are described in Guido's tutorial, though:

    http://www.python.org/2.2/descrintro.html

Look for "property".

leaving-the-activestate-questions-to-activestate-ly y'rs  - tim





More information about the Python-list mailing list