Thanks to the batshit insane way that this works, it's a full-blown method.
This capability isn't unusual. In Python, you can also add methods to instances, but you need to ensure you handle self:
classFoo:def__init__(self):# Some codef=Foo()dir(f)## Returns ['__doc__', '__init__', '__module__']Foo.method=lambdaself,x:xdir(f)## Now includes our new methodf.method(22)## Returns 22.
Languages such as C++ and Java, on the other hand, have immutable types (and in the former, types aren't themselves even a type).
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Right - something like this is fine:
Thanks to the batshit insane way that
this
works, it's a full-blown method.This capability isn't unusual. In Python, you can also add methods to instances, but you need to ensure you handle
self
:Languages such as C++ and Java, on the other hand, have immutable types (and in the former, types aren't themselves even a type).