Extracting name strings from assigned objects

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Shannon Mayne

    Extracting name strings from assigned objects

    I would like to ask how one might obtain the assigned name of an
    assigned object as a string. I would like to use object names as an
    algorithmic input.


    To demonstrate... So if i have:
    >>foo = {}
    what can I do to the object 'foo' so as to return the string 'foo'?

    Thanks!
  • Simon Brunning

    #2
    Re: Extracting name strings from assigned objects

    2008/10/28 Shannon Mayne <shangach@gmail .com>:
    I would like to ask how one might obtain the assigned name of an
    assigned object as a string.
    That's in the FAQ: <http://tinyurl.com/3xkeac>.

    --
    Cheers,
    Simon B.
    simon@brunningo nline.net

    Comment

    • Steven D'Aprano

      #3
      Re: Extracting name strings from assigned objects

      On Tue, 28 Oct 2008 09:23:46 -0700, Shannon Mayne wrote:
      I would like to ask how one might obtain the assigned name of an
      assigned object as a string. I would like to use object names as an
      algorithmic input.
      >
      >
      To demonstrate... So if i have:
      >
      >>>foo = {}
      >
      what can I do to the object 'foo' so as to return the string 'foo'?
      There's a lot of confusion there. The object 'foo' is a string, and it
      doesn't occur anywhere in your code. The name foo is not an object, it is
      a name. Perhaps you meant the object {} (an empty dict)?

      The object {} doesn't know what names (note plural) it has been bound
      too. It could be bound to one name:

      foo = {}

      or many names:

      foo = bar = baz = flib = {}

      or no names at all:

      {}


      Names are not properties of objects. You can't do what you are trying to
      do. If you tell us why you want to do this, perhaps we can suggest a way
      to do it.



      --
      Steven

      Comment

      Working...