Perl's @foo[3,7,1,-1] ?

kj at
Sat Jun 13 16:56:54 EDT 2009

In <mailman.1531.1244920680.8015.python-list at> Jack Diederich <jackdied at> writes:

>There is only so much room in the syntax for common cases before you
>end up with ... perl (no offense intended, I'm a perl monk[1]).   The
>Python grammar isn't as context sensitive or irregular as the perl
>grammar so mylist[1,2,3]  so the "1,2,3" tuple is always interpreted
>as a tuple and the square brackets always expect an int or a slice.
>Not including special cases everywhere means there isn't a short way
>to handle special cases but it also means human readers have to
>remember fewer special cases.   Perl and Python make different
>tradeoffs in that respect.

OK, I see: if Python allowed foo[3,7,1,-1], then foo[3] would be
ambiguous: does it mean the fourth element of foo, or the tuple
consisting of this element alone?  I suppose that's good enough
reason to veto this idea...

Thanks for all the responses.


More information about the Python-list mailing list