Mar-12-2019, 02:23 PM
written this way: def
you must pass a value for parent when instantiating __init__(self, parent):.
if you write it like
then parent is optional when creating an instance of __init__(self, parent):
example with default parent == 'woogie':
__init__(self, parent):
you must pass a value for parent when instantiating __init__(self, parent):.
if you write it like
__init__(self, parent=None):
then parent is optional when creating an instance of __init__(self, parent):
example with default parent == 'woogie':
class IsntImportant(Object): def __init__(self, parent='woogie'): self.parent = parent myclass = IsntImportant() # parent defaults to 'woogie' myotherclass = IsntImportant(parent='main_win') # parent changed to 'main_win'