[Tutor] attribute overwrite
rail shafigulin
rail.shafigulin at gmail.com
Fri Dec 9 22:43:40 CET 2011
i need to overwrite and attribute from the inherited class. i also need to
run the constructor of the super class. here is the code
import datetime
class DateTime(datetime.datetime):
def __init__(self, year, month, day, *args):
super().__init__(year, month, day, *args)
if self.year >= 1000:
self.year = self.year % 1000
i'm getting the following error:
AttributeError: attribute 'year' of datetime.datetime objects are not
writable.
some of you might suggest to change
self.year = self.year % 1000
to
self.yr = self.year % 1000
but i'd need to keep the name the same.
any help is appreciated.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20111209/e97f590d/attachment.html>
More information about the Tutor
mailing list