I can't set an attribute of a function inside of a class. Minimal example:
class Foo:
def bar(self):
pass
f = Foo()
f.bar.attribute = True
For me, this throws an AttributeError: 'method' object has no attribute 'attribute' (setattr(f.bar, 'attribute', True) instead of the last line throws the same error).
Is there a more elegant or pythonic way to set the attribute than f.bar.__dict__['attribute'] = True?