Python to Perl Conversions

Dan Schmidt dfan at
Fri Aug 20 09:39:22 EDT 1999

kernr at (Robert Kern) writes:

| On Fri, 20 Aug 1999 00:27:48 -0500, "Gordon McMillan"
| <gmcm at> wrote:
| >Couple comments -
| >
| >Tom Christiansen wrote:
| >>                                 Yes, slices in python don't include
| >>                                 the termination point.
| >
| >This might be a surprise if you're not used to it, but it turns out 
| >to be very nice. Basically any way of expressing a range will result 
| >in something that includes the left hand side, but excludes the right 
| >hand. So when you're slicing, chopping up, inserting... you (almost) 
| >never have to use "i-1".
| It also means that len(seq[start:end]) == end - start.  It is also
| convenient when using negative indices.

For the record, this is how slicing-style stuff works in the STL in
C++ as well; foo.begin() and foo.end() give you 'first element' and
'one past the end' iterators, and all the generic functions like
for_each take pairs of iterators with that convention.

                 Dan Schmidt -> dfan at, dfan at
Honest Bob & the      
Factory-to-Dealer Incentives ->
          Gamelan Galak Tika ->

More information about the Python-list mailing list