Re: How to get an object's name as a string?

2008-10-29 Thread ShanMayne
The simplest and best option here is to store the objects in a dictionary with their keys being the generated names. Thanks. Indeed Alex, that may well be the simplest way, to have an overarching Dictionary of references/names and objects. However this does not help me to use the

Re: How to get an object's name as a string?

2008-10-29 Thread alex23
On Oct 29, 11:31 pm, ShanMayne [EMAIL PROTECTED] wrote: However this does not help me to use the reference/name of an object I imported instead of created. I've never really understood these requests (and they come up a lot). Unless you're doing a '*' import, you'll already know the bound names

Re: How to get an object's name as a string?

2008-10-29 Thread ShanMayne
Indeed they do. My delighted thanks. You have most precisely addressed the problem I intended to convey. I should have given the case of module attributes a moments further thought, an obvious answer. The locals() was unknown to me (rookie gaps). Thank you for the elaborated illustration. good

Re: How to get an object's name as a string?

2008-10-29 Thread Duncan Booth
Steve Holden [EMAIL PROTECTED] wrote: 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? He didn't ask for the name of a variable, he asked for the name of an object. You

How to get an object's name as a string?

2008-10-28 Thread Shannon Mayne
I would like to create objects with algorithmically determined names based on other object names and use object names for general algorithm input. How would one extract the name of an object from an object instance as a string. I would think that it is stored as an attribute of the object but

Re: How to get an object's name as a string?

2008-10-28 Thread Larry Bates
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 input. How would one extract the name of an object from an object instance as a string. I would think that it is stored as an

Re: How to get an object's name as a string?

2008-10-28 Thread Joe Strout
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 input. What do you mean by the name of an object? Objects don't generally have names, unless you

Re: How to get an object's name as a string?

2008-10-28 Thread Steven D'Aprano
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 input. What do you mean by the name of an

Re: How to get an object's name as a string?

2008-10-28 Thread Steve Holden
Steven D'Aprano wrote: 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 input. What do you

Re: How to get an object's name as a string?

2008-10-28 Thread Joe Strout
On Oct 28, 2008, at 4:45 PM, Steven D'Aprano wrote: 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

Re: How to get an object's name as a string?

2008-10-28 Thread Joe Strout
On Oct 28, 2008, at 6:58 PM, Steve Holden wrote: Objects in Python *don't* have names. Period. In Python we don't normally talk about variables anyway, except when speaking loosely, we talk about binding names. But please don't let this start another round of Python programmers don't know

Re: How to get an object's name as a string?

2008-10-28 Thread alex23
On Oct 29, 12:41 am, Shannon Mayne [EMAIL PROTECTED] wrote: I would like to create objects with algorithmically determined names based on other object names and use object names for general algorithm input. The simplest and best option here is to store the objects in a dictionary with their