Creating a connection object in Python
<p>In a Python software I am working on, I have a number of objects that need to be able to be 'connected' to other objects (the term connected here referring to the fact that it just needs to point to the object it is connected to).</p>

<p>I have thought to create an connection class, which can create this link and store information about the properties of the connection.  As shown below, when I create a new object, I have a method that allows me to add a new connection with a certain type to it.  </p>

<pre><code>class ConnectableObject()
    def addNewConnection(self, connectiontype)
        self.connections.append(NewConnection(connectiontype))
</code></pre>

<p>The idea is that each object should have their own connection type... and that these are connectable.  i.e Object A has a connection object associated with it, Object B has a connection object associated with it, and to connection the two objects I just connect their connections.  That allows me to store information about each connection in the connection objects.  Once this connection object is instantiated I'd like to store in the connection object 'who' created it, i.e object A... object B.  Is there a way in Python to request from an Object what class it was created within?</p>

<p>Also, more generally, is there a cleaner way to implement connections between objects where each object connection can store its own properties?</p>
