Thoughts on PEP284

Sean Ross sross at connectmail.carleton.ca
Tue Sep 23 07:14:57 CEST 2003


"Stephen Horne" <$$$$$$$$$$$$$$$$$@$$$$$$$$$$$$$$$$$$$$.co.uk> wrote in
message
> Personally, I think the conventional '..' has more chance than your
> '...'.

Hi.
Actually, I think '...' is more conventional notation for expressing a range
of numbers. Like when you want to show a sequence:

# odd numbers greater than 3, but less than 257
5, 7, 9, 11, ..., 255, 257

That sort of thing.

Also, '...' is one dot further away from a single dot '.', than is '..'. Is
that important? Maybe. I figure it takes away one argument:

"a..b looks too much like a.b"

by saying

"Well, a...b doesn't"

Of course, a#%$^^#b doesn't either....

Anyway ...


> >Leaving the ellipsis aside, you could add methods to int/long (also ala
> >Ruby),
> >
> >for i in 0.upto(10):
> >    # suite
> >
> ># to count down
> >for i in 10.downto(0):
> >    # suite
>
> I'm not sure about this - I'm bouncing between "that's neat!" and
> "yuck!", but the "yuck!" part may just mean I need to get used to it.
>

I'm more:
I've seen it in Ruby and Smalltalk (where integers have such methods), and
it's not '...' , nor is it range(), so that might be an alternative. Whether
it is a good alternative ... <shrug>. It doesn't add new syntax, only new
methods to existing objects. But, it does not appear to provide any marked
improvement over range (or xrange). So, it's neither here nor there for me.

In my own language, were I to make one,  I would use:

for i in start to stop by step:
    # suite

But, that's not going to happen in this language; neither do I expect it to,
nor would I ask for it (I'd make my own, if I really wanted it).
Still, it's interesting to play with different formulations, to see if they
do or do not work well.






More information about the Python-list mailing list