Bah, I *hate* this particular historical artifact of Python (which
shall be removed in the future...), but there are codes depending on
this.

For example, pyasn1 http://pyasn1.sourceforge.net/ does.

Python originally didn't have slice type, only slice syntax. So Python
converted indicies and passed them to __getslice__. Later, slice type
was introduced and __getslice__ deprecated. For compatibility,
old-style classes still get indicies converted, new-style classes
don't.

class OldStyle:
    def __getitem__(self, index):
        return index

class OldStyleWithLen:
    def __getitem__(self, index):
        return index
    def __len__(self):
        return 10

class NewStyle(object):
    def __getitem__(self, index):
        return index

print NewStyle()[:-1]
print OldStyleWithLen()[:-1]
print OldStyle()[:-1]

Seo Sanghyeon
_______________________________________________
users mailing list
[email protected]
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com

Reply via email to