Thought on PEP 204 and 276

Steve Horne steve at lurking.demon.co.uk
Mon May 27 13:31:11 EDT 2002


I can't help being disappointed that PEP 204 was rejected. To me,

  for i in [0:10] :

is much more intuitive than the PEP 276 version

  for i in 10 :


As for the ideas like allowing '[1, 5:10, 20]', combining the syntax
with list comprehensions, etc I feel the common policy of KISS (ie
just do the minimal slice-like notation) is a good principle.

On the issue that it could be confused with slices, consider the
following...

  (1, 2)

Is that a tuple containing the values 1 and 2, or is it the actual
parameter list for a function call? - you can only tell from the
context (ie was there a function name, variable containing a lambda or
whatever to the left). Clearly the slice/range-list dilemma is no more
confusing than syntax that already exists.

As for being non-obvious, I'd say it's as obvious as using the slice
notation for slices.

In short, PEP 204 seems intuitive to me while PEP 276 makes me worry.

Am I alone in thinking this?

-- 
Steve Horne
steve at lurking.demon.co.uk



More information about the Python-list mailing list