On Thursday, 29 March 2012 21:23:20 UTC+1, Peter  wrote:
> 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

Details here: 
http://stackoverflow.com/questions/399022/why-cant-i-subclass-datetime-date

Jon.
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to