trouble subclassing str
Brent
brent.heeringa at gmail.com
Thu Jun 23 14:49:47 EDT 2005
I'd like to subclass the built-in str type. For example:
--
class MyString(str):
def __init__(self, txt, data):
super(MyString,self).__init__(txt)
self.data = data
if __name__ == '__main__':
s1 = MyString("some text", 100)
--
but I get the error:
Traceback (most recent call last):
File "MyString.py", line 27, in ?
s1 = MyString("some text", 12)
TypeError: str() takes at most 1 argument (2 given)
I am using Python 2.3 on OS X. Ideas?
More information about the Python-list
mailing list