Python Feature Request: Allow changing base of member indices to 1

ici iltchevi at gmail.com
Sat Apr 14 11:32:49 EDT 2007


On Apr 14, 1:27 pm, samj... at gmail.com wrote:
...
> This would mean:
> foo = "foo"
> => foo[1] == 'f'
>

class Str1(str):
    def __getitem__(self,i):
        return str.__getitem__(self,i-1)

s1 = Str1("foo")
print s1[1]




More information about the Python-list mailing list