title: Python : Argument based Singleton
body: <p>I'm following this <a href="https://stackoverflow.com/a/6798042/820410">link</a> and trying to make a singleton class. But, taking arguments (passed while initiating a class) into account so that the same object is returned if the arguments are same.</p>
  
  <p>So, instead of storing class name/class reference as a <code>dict</code> key, I want to store passed arguments as keys in <code>dict</code>. But, there could be unhashable arguments also (like <code>dict</code>, <code>set</code> itself).</p>
  
  <p>What is the best way to store class arguments and class objects mapping? So that I can return an object corresponding to the arguments.</p>
  
  <p>Thanks anyways.</p>
  
  <hr>
  
  <p><strong>EDIT-1</strong> :
  A little more explanation. Let's say there is class as follows</p>
  
  <pre><code>class A:
      __metaclass__ == Singleton
      def __init__(arg1, arg2):
          pass
  </code></pre>
  
  <p>Now, <code>A(1,2)</code> should always return the same object. But, it should be different from <code>A(3,4)</code></p>
  
  <p>I think, the arguments very much define the functioning of a class. Let's say if the class is to make <code>redis</code> connections. I might want to create 2 singletons objects with diff <code>redis</code> hosts as parameters, but the underlying class/code could be common. </p>