deriving from str

Paolo Veronelli paolo_veronelli at yahoo.it
Thu Dec 23 03:29:54 EST 2004


I want to add some methods to str class ,but when I change the __init__ 
methods I break into problems

class Uri(str):
	def __init__(self,*inputs):
		print inputs
		if len(inputs)>1:
			str.__init__(self,'<%s:%s>'%inputs[:2])
		else:
			str.__init__(self,inputs[0])
		print inputs
a=Uri('ciao','gracco')

Traceback (most recent call last):
   File "prova.py", line 9, in ?
     a=Uri('ciao','gracco')
TypeError: str() takes at most 1 argument (2 given)


where is the  str() wrong call.I suppose It's the __new__ method which 
is wrong or me .Thanks for help




More information about the Python-list mailing list