[Python-ideas] Continuation of `__name__` or a builtin function for general name getting

Chris Angelico rosuav at gmail.com
Sun Jun 18 18:27:47 EDT 2017


On Mon, Jun 19, 2017 at 8:16 AM, Alireza Rafiei
<alireza.rafiei94 at gmail.com> wrote:
> I guess I should have framed it as a `quote` for python. You're absolutely
> right that it shouldn't be modifying the assigned object and it doesn't. I
> mentioned the Assign to say that in `x = f`, `x` has name as well, however
> `x.__name__` returns the name of `f` and not `x`.
>
> As for the `f = "hello"`, the value of the name "f" would be "hello" and the
> value of the name "hello" would be "hello".
>
> My proposal is to either change the behavior of `__name__` or have something
> similar that acts globally for all objects and types to get a quote-like
> behavior, provided that the operands of quotes are atomic.

Hmm. So... after x = f,  f.__name__ would be different from x.__name__?

ChrisA


More information about the Python-ideas mailing list