Re: [Python-Dev] string representation of range in 3.0

2008-04-17 Thread Aahz
On Tue, Apr 15, 2008, Guido van Rossum wrote: > On Tue, Apr 15, 2008 at 8:34 PM, Greg Ewing <[EMAIL PROTECTED]> wrote: >> Guido van Rossum wrote: >>> >>> That's why I proposed <0, 1, ..., 9> for repr(range(10)). >> >> My worry is that this will lead a newcomer into thinking >> this is some kind o

Re: [Python-Dev] string representation of range in 3.0

2008-04-16 Thread Terry Reedy
"Guido van Rossum" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] | Why only str()? Note that the interactive prompt uses repr() to display values. I was under the impression that for range, you still wanted to maintain the distinction between an evalable and a friendly representa

Re: [Python-Dev] string representation of range in 3.0

2008-04-16 Thread Greg Ewing
Brad Miller wrote: > I wouldn't include the word "object" in any of these. Everything in Python is an object, so it's just space-wasting noise. -- Greg ___ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-d

Re: [Python-Dev] string representation of range in 3.0

2008-04-16 Thread Brad Miller
I worked up prototype implementation for dict_keys, dict_values, and dict_items Here's an example of what the output looks like: >>> x = {chr(i):i for i in range(68,90)} >>> x.keys() >>> x.values() >>> x.items() >>> comments? Are there other objects in this family that I should look at?

Re: [Python-Dev] string representation of range in 3.0

2008-04-16 Thread Guido van Rossum
No, tp_print is dead, unless I am terribly mistaken. (We didn't remove the slot because that would require updating every single static type initializer.) On Wed, Apr 16, 2008 at 2:39 PM, Christian Heimes <[EMAIL PROTECTED]> wrote: > Guido van Rossum schrieb: > > > Why only str()? Note that the in

Re: [Python-Dev] string representation of range in 3.0

2008-04-16 Thread Christian Heimes
Guido van Rossum schrieb: > Why only str()? Note that the interactive prompt uses repr() to display > values. Does py3k still use the tp_print slot for the interactive prompt? Christian ___ Python-Dev mailing list Python-Dev@python.org http://mail.pyth

Re: [Python-Dev] string representation of range in 3.0

2008-04-16 Thread Guido van Rossum
On Wed, Apr 16, 2008 at 1:16 PM, Terry Reedy <[EMAIL PROTECTED]> wrote: > > "Guido van Rossum" <[EMAIL PROTECTED]> wrote in message > news:[EMAIL PROTECTED] > > > | On Wed, Apr 16, 2008 at 3:15 AM, Armin Rigo <[EMAIL PROTECTED]> wrote: > | > What about the less confusing and more readily genera

Re: [Python-Dev] string representation of range in 3.0

2008-04-16 Thread Terry Reedy
"Guido van Rossum" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] | On Wed, Apr 16, 2008 at 3:15 AM, Armin Rigo <[EMAIL PROTECTED]> wrote: | > What about the less confusing and more readily generalizable: | > | > | > | > It would also be helpful IMHO to use this kind of repr fo

Re: [Python-Dev] string representation of range in 3.0

2008-04-16 Thread Isaac Morland
On Wed, 16 Apr 2008, David Wolever wrote: > On 16-Apr-08, at 9:37 AM, Isaac Morland wrote: >> On Wed, 16 Apr 2008, Paul Moore wrote: >>> On 16/04/2008, Armin Rigo <[EMAIL PROTECTED]> wrote: What about the less confusing and more readily generalizable: It would also be helpfu

Re: [Python-Dev] string representation of range in 3.0

2008-04-16 Thread Guido van Rossum
On Wed, Apr 16, 2008 at 3:15 AM, Armin Rigo <[EMAIL PROTECTED]> wrote: > What about the less confusing and more readily generalizable: > > > > 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

Re: [Python-Dev] string representation of range in 3.0

2008-04-16 Thread Curt Hagenlocher
On Wed, Apr 16, 2008 at 6:58 AM, Steve Holden <[EMAIL PROTECTED]> wrote: > > If you consume values from the iterator to display them in the repr() > where do you then propose to store them until the application wants > them, and how do you distinguish between "real" and "repr" consumption > of the

Re: [Python-Dev] string representation of range in 3.0

2008-04-16 Thread Brad Miller
On Apr 16, 2008, at 5:15 AM, Armin Rigo wrote: > Hi Greg, > > On Wed, Apr 16, 2008 at 03:34:44PM +1200, Greg Ewing wrote: >>> That's why I proposed <0, 1, ..., 9> for repr(range(10)). >> >> My worry is that this will lead a newcomer into thinking >> this is some kind of valid expression syntax. >

Re: [Python-Dev] string representation of range in 3.0

2008-04-16 Thread Nick Coghlan
Isaac Morland wrote: > On Wed, 16 Apr 2008, Paul Moore wrote: > >> On 16/04/2008, Armin Rigo <[EMAIL PROTECTED]> wrote: >>> What about the less confusing and more readily generalizable: >>> >>> >>> >>> It would also be helpful IMHO to use this kind of repr for most built-in >>> iterators and it

Re: [Python-Dev] string representation of range in 3.0

2008-04-16 Thread Steve Holden
Isaac Morland wrote: > On Wed, 16 Apr 2008, Paul Moore wrote: > >> On 16/04/2008, Armin Rigo <[EMAIL PROTECTED]> wrote: >>> What about the less confusing and more readily generalizable: >>> >>> >>> >>> It would also be helpful IMHO to use this kind of repr for most built-in >>> iterators and it

Re: [Python-Dev] string representation of range in 3.0

2008-04-16 Thread David Wolever
On 16-Apr-08, at 9:37 AM, Isaac Morland wrote: > On Wed, 16 Apr 2008, Paul Moore wrote: >> On 16/04/2008, Armin Rigo <[EMAIL PROTECTED]> wrote: >>> What about the less confusing and more readily generalizable: >>> >>> >>> It would also be helpful IMHO to use this kind of repr for most >>> buil

Re: [Python-Dev] string representation of range in 3.0

2008-04-16 Thread Isaac Morland
On Wed, 16 Apr 2008, Paul Moore wrote: > On 16/04/2008, Armin Rigo <[EMAIL PROTECTED]> wrote: >> What about the less confusing and more readily generalizable: >> >> >> >> It would also be helpful IMHO to use this kind of repr for most built-in >> iterators and iterables, instead of their mosty-

Re: [Python-Dev] string representation of range in 3.0

2008-04-16 Thread Paul Moore
On 16/04/2008, Armin Rigo <[EMAIL PROTECTED]> wrote: > What about the less confusing and more readily generalizable: > > > > 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. I quite like this. But as

Re: [Python-Dev] string representation of range in 3.0

2008-04-16 Thread Armin Rigo
Hi Greg, On Wed, Apr 16, 2008 at 03:34:44PM +1200, Greg Ewing wrote: > > That's why I proposed <0, 1, ..., 9> for repr(range(10)). > > My worry is that this will lead a newcomer into thinking > this is some kind of valid expression syntax. What about the less confusing and more readily generaliz

Re: [Python-Dev] string representation of range in 3.0

2008-04-15 Thread Guido van Rossum
On Tue, Apr 15, 2008 at 8:34 PM, Greg Ewing <[EMAIL PROTECTED]> wrote: > Guido van Rossum wrote: > > That's why I proposed <0, 1, ..., 9> for repr(range(10)). > > My worry is that this will lead a newcomer into thinking > this is some kind of valid expression syntax. You and Steven D'Aprano bot

Re: [Python-Dev] string representation of range in 3.0

2008-04-15 Thread Greg Ewing
Guido van Rossum wrote: > That's why I proposed <0, 1, ..., 9> for repr(range(10)). My worry is that this will lead a newcomer into thinking this is some kind of valid expression syntax. -- Greg ___ Python-Dev mailing list Python-Dev@python.org http:/

Re: [Python-Dev] string representation of range in 3.0

2008-04-15 Thread Steven D'Aprano
Hi folks, Been lurking for a while, this is my first post. As I recall, this discussion was started because of concern that Python 3 had introduced features that made it less friendly to beginners. If I can quote Brad Miller: "Several new iterators have appeared in Python 3.0 that makes the

Re: [Python-Dev] string representation of range in 3.0

2008-04-15 Thread Guido van Rossum
That's why I proposed <0, 1, ..., 9> for repr(range(10)). (And I meant the '...' literally, i.e. if there are more than 4 values, replace all but the first two and the last with three dots. And yes, I mean that str(range(4)) == '<0, 1, 2, 3>' but str(range(5)) == '<0, 1, ..., 4>'. I'm not at all s

Re: [Python-Dev] string representation of range in 3.0

2008-04-15 Thread Greg Ewing
Brad Miller wrote: > It was suggested that a broader discussion might be in order around the > issue of iterators and how they are displayed in the command line > interpreter. Whatever is done, I don't think it would be a good idea to make the str() of these things look *too* much like a list. I

Re: [Python-Dev] string representation of range in 3.0

2008-04-14 Thread Brad Miller
After posting a patch to implement this some good discussion followed see: http://bugs.python.org/issue2610 It was suggested that a broader discussion might be in order around the issue of iterators and how they are displayed in the command line interpreter. Several new iterators have app

Re: [Python-Dev] string representation of range in 3.0

2008-04-07 Thread Guido van Rossum
I'd object to it returning something that resembles a list too closely, but I could live with str(range(3)) return <0, 1, 2>. We should probably have a cutoff so that if there are more than 6 values it'll show the first 3 values, then dots, then the last 2 values. (The cutoff would be computed so t

[Python-Dev] string representation of range in 3.0

2008-04-07 Thread Brad Miller
Hi, I use Python in my CS1 and CS2 curriculum and I have a question. As I've been using the Python 3.0 alphas one of the things that I am bothered by is that I cannot see the sequence produced by range without introducing students to the list() function. I typically introduce range on day 1 o