[Tutor] introspection

Danny Yoo dyoo at hashcollision.org
Tue Apr 21 19:20:45 CEST 2015


> But I see what I think you and others have been trying to explain to me:
> that the expression some_object.__name__, if it existed, would indeed be
> schizophrenic since it would be an attribute of the object, not the name(s)
> to which  it is bound.


The hypothetical feature might also, if designed badly, break simple
things like checking for equality.  e.g. say that we do:

    x = # ... some value
    y = copy.deepcopy(x)

Would x == y?  From my understanding, if the object were automatically
associating a __name__, it should not.  And that would be weird.  :P

This is not to say that what you're asking for is unreasonable!   It's
just that Python doesn't do it, and introducing such a feature in
Python would have large implications in terms of what it means, not to
mention how it might affect the runtime.


More information about the Tutor mailing list