On 01.12.2017 1:19, Greg Ewing wrote:
Ivan Pozdeev via Python-ideas wrote:
I needed to hold an external function reference in an object instance (if I assigned it to an attribute, it was converted into an instance method).
No, that only happens to functions stored in *class* attributes, not instance attributes.
... pass ...
a = A()
... print("I'm just a function") ...
a.x = f a.x()
I'm just a function
Well, yes, that was a singleton class, so I kept data in the class object. Now I can simplify the code by only keeping the instance reference in the class, thank you. (Without knowing this, that bore no visible benefits.)