title: Calling a dictionary outside the class in main() block in python
body: <p>I have two python scripts as below.</p>
  
  <p>first.py:</p>
  
  <pre><code>from second import Y
  class X(object):
  
    def __init__(self):
     self.dict = dict()
  
    def test1(self):
     dict = {'a':'1','b':'2'}
     self.dict = dict
     return dict
  
    def action(self):
     performance = Y()
     performance.test2(**self.dict)
  </code></pre>
  
  <p>second.py:</p>
  
  <pre><code>class Y(object):
    def test2(self,**dict):
    return dict
  
  if __name__ == '__main__'
    xinst = X()
    xinst.action()
    finaltest = Y()
    finaltest.test2()
  </code></pre>
  
  <p>I see the dict printing with correct information when printing in method <code>test2</code> (under class <code>Y</code>). But an empty dict (<code>{}</code>) is returned when I try to call it under <code>if __name__ == '__main__'</code>. Can anyone please help me/suggest me what I am doing wrong?    </p>