What is a clean “pythonic” way to implement multiple constructors?
Actually None is much better for “magic” values: class Cheese(): def __init__(self, num_holes = None): if num_holes is None: … Now if you want complete freedom of adding more parameters: class Cheese(): def __init__(self, *args, **kwargs): #args — tuple of anonymous arguments #kwargs — dictionary of named arguments self.num_holes = kwargs.get(‘num_holes’,random_holes()) To better explain the … Read more