Subclassing: what is wrong here?

Paulo da Silva psdasilvaX at esotericaX.ptX
Thu Mar 15 20:02:13 EDT 2007


Hi!

What's wrong with this way of subclassing?

from datetime import date

class MyDate(date):
	def __init__(self,year,month=None,day=None):
		if type(year) is str:
			# The whole date is here as a string
			year,month,day=map(int,string.split(year,'-'))
		if year<100:
			year+=2000
		date.__init__(self,year,month,day)

When I do
d=MyDate("2007-3-15")
I got
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
TypeError: function takes exactly 3 arguments (1 given)

Thanks for any help.



More information about the Python-list mailing list