assigning an object's name taken from expression
<p>I need to extract data from external source. I build a base clas with some structure. I need objects with type of myBase class but with a name which automatically describes how many times I iterate over the source. I build a class which stores this number and with a call method which returns the object I need. I can't find a way to have a string as the name for the object but automatically differ every time I build new object.
I simplified the code for this example: </p>

<pre><code>class myBase:
    def __init__(self):
        iteratedValue = None

class myIterator:
    def __init__(self):
        self.k = 0
    def __call__(self, s):
        self.k += 1
        self.name = 'myData' + str(self.k)
        # create an object named myData1, myData2 ...
        self.name = myBase() 
        self.name.iteratedValue = s 
        print '%s name is %s for k = %i' % (self.name, self.name.iteratedValue, self.k)

        # return object named myData1 type of myBase
        return self.name

def DataExtraction():
    # function to extract data form external source
    data = myIterator()
    data('Alice') 
    data('Ben') 

DataExtraction()
</code></pre>

<p>My output is:</p>

<pre><code>&lt;__main__.myBase instance at 0x7f261b6dc6c8&gt; name is Alice for k = 1
&lt;__main__.myBase instance at 0x7f261b6dc6c8&gt; name is Ben for k = 2
</code></pre>

<p>I need to return an object with a specific name and I expect an output:</p>

<pre><code>myData1 name is Alice for k = 1
myData2 name is Ben for k = 2
</code></pre>

<p>The original problem is much more complicated. I have external data and every time they come I want to extract some values from this data. Every time I am doing this I need an object to work with it but I need this object with different names because on the end I store them in dict for another methods. In other words I work with data and store my results in the object <code>myData1</code> when the original data change I work with it again and store the results in <code>myData2</code> etc. After all I need all <code>myData</code> objects and do statistics on them to see how the change. I do not have access to original data any more. I need automatic name convention for <code>myData</code> and the best if it will express iterator.</p>

<p>How can I have a string in place of <code>self.name</code> as the name for an object?</p>
