title: difference between locals() and globals() and dir() in python
body: <p>assume this code :</p>
  
  <pre><code>&gt;&gt;&gt; iterator=filter(lambda x: x % 3 == 0, [2, 18, 9, 22, 17, 24, 8, 12, 27])
  &gt;&gt;&gt; x=int()
  &gt;&gt;&gt; locals()
  {'__package__': None, '__spec__': None, '__loader__': &lt;class '_frozen_importlib.BuiltinImporter'&gt;, '__name__': '__main__', '__builtins__': &lt;module 'builtins' (built-in)&gt;, 'iterator': &lt;filter object at 0x02E732B0&gt;, 'x': 0, '__doc__': None}
  &gt;&gt;&gt; globals()
  {'__package__': None, '__spec__': None, '__loader__': &lt;class '_frozen_importlib.BuiltinImporter'&gt;, '__name__': '__main__', '__builtins__': &lt;module 'builtins' (built-in)&gt;, 'iterator': &lt;filter object at 0x02E732B0&gt;, 'x': 0, '__doc__': None}
  &gt;&gt;&gt; dir()
  ['__builtins__', '__doc__', '__loader__', '__name__', '__package__', '__spec__', 'iterator', 'x']
  &gt;&gt;&gt; 
  </code></pre>
  
  <p>what is the difference between locals,globals and dir ? and what is the usage ?</p>