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.
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to