I am attempting to subclass the date class from the datetime package. Basically 
I want a subclass that can take the date as a string (in multiple formats), 
parse the string and derive the year,month and day information to create a date 
instance i.e. 

class MyDate(datetime.date):
  def __init__(self, the_date):
    # magic happens here to derives year, month and day from the_date
    datetime.date.__init__(self, year, month, day)

But no matter what I do, when I attempt to create an instance of the new class, 
I get the error message:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: Required argument 'year' (pos 1) not found


I have even created a class which doesn't include the argument I want to use 
but with default arguments i.e.

class MyDate (datetime.date):
  def __init__(self, year = 1, month = 1, day = 1):
    datetime.date.__init__(self, year, month, day)

and get the same error message.

What am I doing wrong here? 

Thanks for any help,
Peter
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to