[Python-ideas] Add a dict with the attribute access capability

Greg Ewing greg.ewing at canterbury.ac.nz
Thu Nov 30 17:19:49 EST 2017

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.

 >>> class A:
...    pass
 >>> a = A()
 >>> def f():
...    print("I'm just a function")
 >>> a.x = f
 >>> a.x()
I'm just a function


More information about the Python-ideas mailing list