[Pythonmac-SIG] (no subject)
Keith Nemitz
keithn at 2xtreme.net
Sat Jan 31 13:57:20 EST 2004
>>
>>
>> huh? I mean does everyone use[-3:] instead and 0 is taboo? I'm used
>> to the Icon programming language where "food"[-3:0] returns --> ood
>
> "food"[-3:] is equivalent to "food"[-3:None] (that is, literally, how
> it works out internally)
>
> "food"[-3:0] is just backwards :) If anything, it should give you
> "oof", but that's too confusing.
>
> -bob
>
Thank you. I knew there had to be a reason. If you think about lists as
ring buffers, however, then "food"[-3:0]-->"ood" makes plenty of
sense and can be very useful. My case that started this whole thread
had to do with iterating from negative to positive, returning larger
substrings on each iteration. It broke with the zero index. So I had to
special case it.
sigh, I wonder if adding this 'concept' to python (indexing lists as
ring buffers) would break any existing code...
Heck while I'm at it, changing the language, might as well add nested
comments, and (my personal favorite) record names, implemented like
this:
record <tuple of enums>
tuple of enums ::= (<enum> [,enum]*)
enum ::= <string>[= <int>]
...such that the keyword 'record' turns the strings into module and/or
class scoped indexes.
Isn't it fun to dream?
Keith Nemitz
More information about the Pythonmac-SIG
mailing list