Greg Ewing wrote:
> Guido van Rossum wrote:
> 
>> Actually, the autowrapping was intended a backwards compatibility measure.
> 
> But it seems like a perfectly good and useful feature
> in its own right to me. Why force every sequence to
> implement its own __iter__ if there is a default one
> that does the same as what your custom one would have
> done anyway?

The standard sequence iterator should still be somewhere in the standard 
library (e.g. as itertools.seqiter). This could then be used by assigning it 
as the __iter__ method in a class definition, or to a tp_iter slot through the 
C API.

The fallback shouldn't be in iter() itself because falling back on the 
sequence iterator is a bug when __getitem__ and __len__ are used to implement 
a mapping.

Alternatively, if a mechanism is introduced to allow a class to explicitly 
flag itself as "I'm a sequence", then iter() could be changed to only use the 
sequence iterator if that marker was set.

Cheers,
Nick.

-- 
Nick Coghlan   |   [EMAIL PROTECTED]   |   Brisbane, Australia
---------------------------------------------------------------
             http://www.boredomandlaziness.org
_______________________________________________
Python-3000 mailing list
Python-3000@python.org
http://mail.python.org/mailman/listinfo/python-3000
Unsubscribe: 
http://mail.python.org/mailman/options/python-3000/archive%40mail-archive.com

Reply via email to