[Python-Dev] string representation of range in 3.0
Guido van Rossum
guido at python.org
Wed Apr 16 23:20:24 CEST 2008
On Wed, Apr 16, 2008 at 1:16 PM, Terry Reedy <tjreedy at udel.edu> wrote:
>
> "Guido van Rossum" <guido at python.org> wrote in message
> news:ca471dc20804160757u6a0257c8rff1ab5f68b5fc698 at mail.gmail.com...
>
>
> | On Wed, Apr 16, 2008 at 3:15 AM, Armin Rigo <arigo at tunes.org> wrote:
> | > What about the less confusing and more readily generalizable:
> | >
> | > <range object 0, 1, ..., 9>
> | >
> | > It would also be helpful IMHO to use this kind of repr for most
> built-in
> | > iterators and iterables, instead of their mosty-useless default repr.
> |
> | We can't do this for iterators, since you can't print the values
> | without consuming the iterator. Printing something shouldn't have a
> | side effect on it. But for iterables (e.g. dict views) it should work
> | fine, and if others can agree with this I'd be happy to accept
> | patches.
>
> Assuming we are discussing the output of str() rather that repr(),
> I think we should give Armin's idea a try for iterables that don't get the
> full display
> (as with lists, etc) but can harmlessly produce some values.
Why only str()? Note that the interactive prompt uses repr() to display values.
--
--Guido van Rossum (home page: http://www.python.org/~guido/)
More information about the Python-Dev
mailing list