Exceptions, assigning a tuple
Erik Max Francis
max at alcyone.com
Fri Nov 21 16:55:55 EST 2003
"Gonçalo Rodrigues" wrote:
> Hmm. More generally you have to implement __iter__ for a class to be
> iterable, be in for loops => can be list-ified, tuple-ified,
> etc.-ified.
Defining an explicit __iter__ method is another way, and is particularly
useful when you're dealing with a class whose iteration can be
encapsulated easily in a separate iterator object that you can return
(and you're running Python 2.2 or up). That isn't always the case.
--
Erik Max Francis && max at alcyone.com && http://www.alcyone.com/max/
__ San Jose, CA, USA && 37 20 N 121 53 W && &tSftDotIotE
/ \
\__/ Golf is a good walk spoiled.
-- Mark Twain
More information about the Python-list
mailing list