On 5/3/2017 6:21 PM, Larry Martell wrote:
On Wed, May 3, 2017 at 6:15 PM, Terry Reedy <tjre...@udel.edu> wrote:
Python already uses this trick for functions, classes, and modules by giving
them .__name__ attribute. Code objects have a .co_name attribute. These
are used for tracing and tracebacks.
I left out the most important use -- in string presentations.
def f(): pass
print(f)
'<function f at 0x0000019F17053D90>' (guaranteed to be unique!)
But not for a variable like a list or dict?
Numbers and collections are better represented by their value.
Making the .__name__ of 123 be 'one hundred twenty three' or the
.__name__ of [1,2,'abc'] be 'list of one, two, (string of a, bee, cee)'
would not be generally helpful ;-).
--
Terry Jan Reedy
--
https://mail.python.org/mailman/listinfo/python-list