Using variables as objects in python
<p>I am attempting to write a script that connects to various databases in MongoDB via pymongo, 
however ive come to a little stumbling block:</p>

<p>I have a list of collection names in an array which i would like to store and access in a dictionary later on in the running of the script, </p>

<p>so i have </p>

<pre><code>class RA():
    class Meta:
        connection_dict = {}
        connection_array = [a,b,c,d,e,f,g,h]

    def __init__(self):
        self.open_connections()

    def open_connections(self):
        import pymongo

        connection = pymongo.Connection('localhost')
        db_connection = connection.db_namae

        for con_id in self.Meta.connection_array:
            self.Meta.connection_dict.update({con_id : db_connection.con_id})
</code></pre>

<p>as it stands this just creates a dict of n entries all connected to db_connection.con_id:</p>

<p>So the question is how do i use variables in that final line to create different connections rather then just connect to the db_connection.con_id? As beforehand i may not be able to hardcode these connections in, due to their being too many or an increment in number of them in the future</p>

<p>--Edit:</p>

<p>Sorted this now: finally found a different way of getting around the connection issue with pymongo,</p>
