3 ms·
> you can't add new methods post-hoc to types in Python Unless I'm misunderstanding what that means, you totally can: >>> class Foo: ... def bar(s
by Doxin 5y ago
> you can't add new methods post-hoc to types in Python
Unless I'm misunderstanding what that means, you totally can:
>>> class Foo:
... def bar(self):
... return 3
...
>>> foo = Foo()
>>> foo.bar()
3
>>> Foo.baz = lambda self: 6
>>> foo.baz()
6
>>>