[Pythonmac-SIG] (no subject)

Bob Ippolito bob at redivi.com
Sat Jan 31 14:14:23 EST 2004


On Jan 31, 2004, at 1:57 PM, Keith Nemitz wrote:

>>> 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.
>>
> 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.

They aren't ring buffers, they're arrays.. the fact you can use 
negative indexes is a convenience really.. if you notice, you can do 
"food"[1:100000] and you will still get "ood".  You get clipped at the 
boundaries when slicing.

> sigh,  I wonder if adding this 'concept' to python (indexing lists as 
> ring buffers) would break any existing code...

Yes, I'm sure it would.. you could make a subclass of str (or list, or 
whatever) or a proxy object to address things as a ring buffer though.

> Heck while I'm at it, changing the language, might as well add nested 
> comments, and (my personal favorite) record names, implemented like 
> this:

Nested comments?

> 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.

You don't need language support for this, definitely not a keyword.

-bob
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 2357 bytes
Desc: not available
Url : http://mail.python.org/pipermail/pythonmac-sig/attachments/20040131/a4b41e50/smime.bin


More information about the Pythonmac-SIG mailing list