Python to Perl Conversions
Dan Schmidt
dfan at harmonixmusic.com
Fri Aug 20 09:39:22 EDT 1999
kernr at mail.ncifcrf.gov (Robert Kern) writes:
| On Fri, 20 Aug 1999 00:27:48 -0500, "Gordon McMillan"
| <gmcm at hypernet.com> 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 harmonixmusic.com, dfan at alum.mit.edu
Honest Bob & the http://www2.thecia.net/users/dfan/
Factory-to-Dealer Incentives -> http://www2.thecia.net/users/dfan/hbob/
Gamelan Galak Tika -> http://web.mit.edu/galak-tika/www/
More information about the Python-list
mailing list