I am really confused by this whole thread:

(I know this has all been said in this thread, but I’m summarizing to get
us on the same page for the following comments)

Python has names, and it has values (objects, whatever) when we write
Python, we bind names to values with the = operator. (And other namespace
trickery). Some types of objects do have a __name__ attribute: classes,
functions created with def.

But that name is only sometimes the same as the name(s) it might be bound
to in any given namespace. So what the heck is nameof() supposed to mean? A
few examples:

>>> x = 5
>>>nameof(x)

OK, I suppose that’s “x” — but what is the point of that? You have to know
the name already.

What about:

y = 5
x = 5
(Or x = y)

What is nameof(x) And nameof(y)?

What about nameof(5)?

Now:

def fun():
    pass

I suppose nameof(fun) is “fun”, but again, is that useful?

And now:

Fred = fun

What’s nameof(Fred)

If it’s “Fred” then again, useless.

If it’s “fun” then what about x and y before?

And:

def fun():
    y = something
    return y

lst.append(fun())

nameof(lst[-1])

????

In short, if it means “what is the name of this name” that seems completely
useless?

If it means: what name is this object bound to in this namespace? Than I
can see how one might think that would be useful, but the answer could be:

No name at all
More than one name
A name different than the object’s __name__

And then there is the question of the local vs global namespace, the list
goes on.

This thread has been going on a while:

What am I missing?

-CHB







>
>
-- 
Christopher Barker, PhD

Python Language Consulting
  - Teaching
  - Scientific Software Development
  - Desktop GUI and Web Development
  - wxPython, numpy, scipy, Cython
_______________________________________________
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-le...@python.org
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at 
https://mail.python.org/archives/list/python-ideas@python.org/message/ZDMNZVJJMX26M5B2VUWRLC6NDKUXTH4J/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to