Re: is it possible to add a property to an instance?
Darren Dale wrote to GHUM: Sorry, that's an attribute, not a property. This is a question about terminology. In contrast to Darren's recommended usage, I have run into the following. If hasattr(x,'a') is True, for instance object `x`, then `a` is an attribute of `x`. Attributes are data attributes or callable attributes. Data attributes are variables or properties. Callable attributes are usually method attributes. This seemed about right to me, but a better (or official) taxonomy would be welcome. Thanks, Alan Isaac -- http://mail.python.org/mailman/listinfo/python-list
Re: is it possible to add a property to an instance?
Does anyone know if it is possible to add a property to an instance at runtime? I didn't see anything about it in the standard library's new module, google hasn't turned up much either. yes. You need nothing special, just add it: class fish(object): pass a=fish() a.legs=4 print a.legs (or print (a.legs) on Python 3.0 and above) so you add a property to an instance and proove that Darwin was right in one go. Harald -- http://mail.python.org/mailman/listinfo/python-list
Re: is it possible to add a property to an instance?
GHUM wrote: Does anyone know if it is possible to add a property to an instance at runtime? I didn't see anything about it in the standard library's new module, google hasn't turned up much either. yes. You need nothing special, just add it: class fish(object): pass a=fish() a.legs=4 print a.legs Sorry, that's an attribute, not a property. -- http://mail.python.org/mailman/listinfo/python-list