How to get an object's name as a string?
steve at REMOVE-THIS-cybersource.com.au
Tue Oct 28 23:45:18 CET 2008
On Tue, 28 Oct 2008 09:15:50 -0600, Joe Strout wrote:
> On Oct 28, 2008, at 8:41 AM, Shannon Mayne wrote:
>> I would like to create objects with algorithmically determined names
>> based on other object names and use object names for general algorithm
> What do you mean by the "name" of an object? Objects don't generally
> have names, unless you explicitly define a .name property and assign
> them names.
> (Variables have names, of course, but a variable isn't an object -- it's
> just a reference to an object. Many variables may refer to the same
> object, so it doesn't make any sense to ask for the name of THE variable
> which may be referring to an object at the moment.)
That explanation makes no sense. Given the assignment:
x = 57
if the name of x isn't 'x', then what on earth can it possibly mean to
ask for the name of a variable?
In languages like Python, the term "variable" is misleading and
confusing. Python's programming model has objects (values), and names.
Best to use language that describes what Python actually does, rather
than use language that describes what other languages do.
More information about the Python-list