On 2019-02-27 05:25, AdamC wrote:
That's great - bug found. Thanks. However the next question is, how do I create an instance of a class with variable parameters (i.e. with dateAdded already computed and stored, or with dateAdded created for the first time)?

Might this work?

class myClass(object):
  __init__(self, added_date=None):
        if added_date:
            self.date_attribute = added_date
        else:
            self.date_attribute = my_way_of_calculating_added_date()

You can then instantiate in either of these ways:

my_instance = myClass()

or

my_instance = myClass(my_way_of_calculating_added_date())
_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor

Reply via email to