How can I use an attribute of the instance as a default argument for a method? [duplicate]
You can’t really define this as the default value, since the default value is evaluated when the method is defined which is before any instances exist. The usual pattern is to do something like this instead: class C: def __init__(self, format): self.format = format def process(self, formatting=None): if formatting is None: formatting = self.format print(formatting) … Read more