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.
_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

Reply via email to