Re: Problem redefining __getitem__ for str subclass

2007-04-21 Thread Alex Martelli
<[EMAIL PROTECTED]> wrote: > I do not think I am understanding how to redefine the getitem function > for string. Why does the following not work: > > class NStr(str): > def __getitem__(self,idx): > print "NStr:getitem",idx,type(idx) > return str.__getitem__(self,idx) > > s=N

Re: Problem redefining __getitem__ for str subclass

2007-04-21 Thread Carsten Haese
On 21 Apr 2007 20:36:13 -0700, tsm8015 wrote > I do not think I am understanding how to redefine the getitem > function for string. Why does the following not work: > > class NStr(str): > def __getitem__(self,idx): > print "NStr:getitem",idx,type(idx) > return str.__getitem__(

Re: Problem redefining __getitem__ for str subclass

2007-04-21 Thread Michel Claveau
Hi! Same result, with Python 2.5.1 on win-XP; I have compassion with you. -- @-salutations Michel Claveau -- http://mail.python.org/mailman/listinfo/python-list

Problem redefining __getitem__ for str subclass

2007-04-21 Thread tsm8015
I do not think I am understanding how to redefine the getitem function for string. Why does the following not work: class NStr(str): def __getitem__(self,idx): print "NStr:getitem",idx,type(idx) return str.__getitem__(self,idx) s=NStr("abcde") print s[1] print s[1:4:2] print