Status of PEP's?

James_Althoff at i2.com James_Althoff at i2.com
Tue Mar 5 15:47:26 EST 2002


[Greg Ewing]
> It's been suggested that this proposal doesn't ask
> us to think of integers as being sequences, only as
> having sequences implicitly associated with them.

Going beyond suggesting, I hereby *command* you not to think of integers as
being sequences <wink>.

> But I don't agree. While it's certainly possible
> to give any object an __iter__ method that does
> anything you want, it doesn't mean you should!

Right.  Unless it's useful and practical to do so (exclamation point right
back at ya <wink>).

> To me, the __iter__ protocol is intended to be used
> when an object can reasonably be thought of as a
> sequence. That's actually *being* a sequence, not just
> "associated" with a sequence in some way.

I think that view of iterators is overly restrictive.  An example is dict.
I don't have to think that a dict object *is* a sequence to be content with
it being a valid arg to iter().  For me, it's fine to write
    for x in mydict: print x
and think "this works because there is a useful and practical sequence
*associated* with mydict (namely, a sequence of the keys in mydict)".

And keep on writing code <wink>.

Jim





More information about the Python-list mailing list