in reply to Re^6: Converting python list range expressions to perl
in thread Converting python list range expressions to perl

> Unless a or b is negative in which case .. hell, I don't remember ;-)

AFAIR from a previous discussion is Perl using closed intervals while Python using half open ones.

That means the end point is excluded in Python.

One advantage is that [:X] and [X:] are splitting an interval including X exactly into two dijoint parts, without needing to decrement the first end boundary.

I.O.W always $end-- when translating to Perl.

Cheers Rolf
(addicted to the 𐍀𐌴𐍂𐌻 Programming Language :)
Wikisyntax for the Monastery

Replies are listed 'Best First'.
Re^8: Converting python list range expressions to perl
by ibm1620 (Hermit) on Dec 05, 2022 at 22:58 UTC
    Personally I prefer offset/length-type expressions, as in substr(), to begin/end expressions of Perl slices and Python ranges, especially when it comes to the way negative values work. I'm sure it's just a matter of familiarity, though.