How to get the name of a created object (not the class itself) in Python 3.X : <p>I've always wondered if when you define a variable, you can somehow get the name you defined it with, and manipulate it as a string. I am trying to make some code more efficient in doing this.</p>

<p>I looked this up and didn't seem to hit the spot with what I found. I found some code that can retrieve the name of the class itself, but not the name of the created object.</p>

<pre><code>class A:
    @classmethod
    def getname(cls):
        return cls.__name__

    def usename(self):
        return self.getname()

&gt;&gt; example = A()
&gt;&gt; print (example.usename())
A
</code></pre>

<p>I thought I would get a result looking like this: </p>

<pre><code>example
</code></pre>

<p>It being literally the name of the object, not the class.</p>

<p>Is there a way of doing this? If there is, I would really appreciate it. </p>

<p>PS: if this question turns out to be a duplicate, sorry, would love it if ya'll point me to the answer :) and not delete this.</p>
