Proposal to add __str__ method to iterables:
Proposed behavior of the __str__ method for iterables is that it
returns the result of "".join(str(i) for i in self).
Justification:
Notice this difference in the behavior of filter* and a list
comprehension:
>>> filter(lambda c: c!="a", "abra
anymore! Someone should fix that to say Sequence instead.
Thanks,
Carl Johnson
___
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
n
feeling is that these two cases should behave the same way, but I
could be wrong.
I hope this isn't an old issue, but I've been lurking for a few months
and haven't heard any discussion of this.
-- Carl Johnson
___
Python-3000
Filed http://bugs.python.org/issue3331
I added this to the bottom of the report, but perhaps it should be a
discussion topic, not a "bug" per se:
One might object that the behavior of the list comprehension is
identical to that of a for-loop:
>>> r = []
>>> for x in range(100):
own
feeling is that these two cases should behave the same way, but I
could be wrong.
I hope this isn't an old issue, but I've been lurking for a few months
and haven't heard any discussion of this.
-- Carl Johnson
___
Python-3000
ry:
#if spec contains letters not understood, __format__
raises NI
return obj.__format__(spec)
except NotImplemented:
pass #everything gets put through str as a last resort
return str(obj).__format__(spec) #last chance before throwing
exception