title: Python - Class list and dictionnary linked between instance
body: <p>I got a strange behavior with python class, that doesn't seem normal to me, could you take time to help me on that ?</p>
  <p>The code has been executed under python 3.9 and 3.6.</p>
  <p>I got multiple instances from the same class:</p>
  <pre class="lang-py prettyprint-override"><code>class Obj:
      txt_list = []
      txt_dictionnary = {}
      txt_var = &quot;&quot;
  
      def __init__(self, txt):
          self.txt_list.append(txt)
          self.txt_dictionnary[&quot;hello&quot;] = txt
          self.txt_var = txt
  </code></pre>
  <p>Main code :</p>
  <pre class="lang-py prettyprint-override"><code>if __name__ == '__main__':
      Obj1 = Obj(&quot;1&quot;)
      print(f&quot;txt_list1 = {Obj1.txt_list} - txt_dictionnary1 = {Obj1.txt_dictionnary} - txt_var1 = {Obj1.txt_var}&quot;)
      Obj2 = Obj(&quot;2&quot;)
      print(f&quot;txt_list1 = {Obj1.txt_list} - txt_dictionnary1 = {Obj1.txt_dictionnary} - txt_var1 = {Obj1.txt_var}&quot;)
      Obj2.txt_list.append(&quot;3&quot;)
      print(f&quot;txt_list1 = {Obj1.txt_list} - txt_dictionnary1 = {Obj1.txt_dictionnary} - txt_var1 = {Obj1.txt_var}&quot;)
  </code></pre>
  <p>Output :</p>
  <pre><code>txt_list1 = ['1'] - txt_dictionnary1 = {'hello': '1'} - txt_var1 = 1
  txt_list1 = ['1', '2'] - txt_dictionnary1 = {'hello': '2'} - txt_var1 = 1
  txt_list1 = ['1', '2', '3'] - txt_dictionnary1 = {'hello': '2'} - txt_var1 = 1
  </code></pre>
  <p>For me <code>Obj1</code> shouldn't be changed when I instantiate and modify the <code>Obj2</code> since <code>Obj1</code> and <code>Obj2</code>.
  We also see, only the simple variable don't change on modification/instantiation.
  Did I forget something ?</p>