PEP 284, Integer for-loops

Steve Lamb grey at despair.dmiyu.org
Wed Mar 6 21:11:45 EST 2002


On Wed, 06 Mar 2002 17:57:57 -0800, David Eppstein <eppstein at ics.uci.edu>
wrote:
> I started with a positive number n, 

    Actually, you never defined what n was, positive or negative.  It could
have been either.  I decided to start with a negative.

> and claimed that it was hard to create and understand expressions such as
> range(n-1,-1,-1).  You said that if that was so hard, I should instead
> simply create range(n-1,0) and reverse it.
 
> range(n-1,0) is empty when n is positive.  You should have told me to 
> reverse range(n).  So, clearly, you did not understand the expression 
> range(n-1,-1,-1), contradicting your claim that range is easy to 
> understand.

    No, I decided that one might want to do something funky like:
n=-9
range(n-1)

    That yields an empty set.  

    Now, if you'd like to clearly define what N was beforehand instead of
worrying about presumptions only you hold you might just have something.

> I agree, there are already ways to do it. There are already ways to do 
> everything you might ever want to do in Python, because like most 
> sensible languages it's Turing-complete.  So should we stop trying to 
> improve the language?

    No.  However, building in specific case statements for narrow range
perception problems is not improving the language, it is degrading it.

> that the proposed syntax gives a simple easy-to-understand alternative.

    Easy-to-understand to David Eppstien, not to others.  I do believe you
nailed me with that, didn't you?

> Anyway, according to
><http://groups.google.com/groups?selm=001101beae49$39af7bc0$949e2299@tim>
> it's not a problem if there's more than one way of doing things, but 
> there should preferably one obvious way.  This proposal would give one 
> obvious way of doing most integer loops.

    Which we can already do.  We also don't want to build in special syntax
for every special case.  See any discussion on while(1):.

> That's not covered by the current proposal.  It's supposed to be an 
> improvement, not a panacea -- now is a good time for another Tim-quote 
> "now is better than never", which is what we'll get if we wait for a 
> perfect solution to all our problems.

    How about coming up with your own arguments instead of quoting others.
Just because someone's got a bug up their butt about their shortcomings and
has a woody for some solution looking for a problem doesn't mean it should be
implemented without thought or consideration.

    Point, after several messages, still stands.  PEP is too restrictive,
doesn't do anything other than complicate the language, has no compelling
reason to be implemented, is nothing more than special syntax to solve one
person's special nitpick.

-- 
         Steve C. Lamb         | I'm your priest, I'm your shrink, I'm your
         ICQ: 5107343          | main connection to the switchboard of souls.
    To email: Don't despair!   |  -- Lenny Nero, Strange Days
-------------------------------+---------------------------------------------



More information about the Python-list mailing list