[Python-ideas] objects aware of being bound to a name
ncoghlan at gmail.com
Sun Jun 5 07:50:30 CEST 2011
On Sun, Jun 5, 2011 at 11:54 AM, Terry Reedy <tjreedy at udel.edu> wrote:
> Functions, classes, and modules have __name__ attributes (that cannot be
> deleted, even if they can be replaced). This attribute is set before they
> are optionally bound, so they also do not hear about the subsequent
> bindings. This attribute is used for their string representations for humans
> to read. I cannot think of any other use by the interpreter itself.
__name__ attributes are also relevant for serialisation (esp. pickling).
However, due to immutable objects, there's no realistic general
purpose solution in this space.
Nick Coghlan | ncoghlan at gmail.com | Brisbane, Australia
More information about the Python-ideas