Barry Warsaw wrote:
> I wouldn't want to generalize this, but it is not infrequent that
> people mistakenly iterate over strings when they want to treat them
> atomically. difflib not withstanding, and keeping Guido's
> pronouncement in mind, I do think people want to treat strings
> atomically much more often then they want to treat them as a sequence
> of characters.
Perhaps we need a "no really - I really want to iterate over this thing"
built-in and magic method. Then things that should generally be treated
atomically would not implement __iter__, but could implement
__deep_iter__ (which would return a standard iterator).
This would allow both use cases, but atomicity being the default (i.e. a
for loop continues to use __iter__).
for e in deep_iter(obj):
print e
Tim Delaney
_______________________________________________
Python-3000 mailing list
[email protected]
http://mail.python.org/mailman/listinfo/python-3000
Unsubscribe:
http://mail.python.org/mailman/options/python-3000/archive%40mail-archive.com