title: How to call a Python function like in Javascript
body: <p>if i do this , it will be ok :</p>
  
  <pre><code>def a():
      b = [1,2,3]
      def d():
          print b
      d()
  
  a()
  </code></pre>
  
  <p>but i have many method  need function <strong>d</strong> , so i have to defined it out of the function <strong>a</strong> , but it show error :</p>
  
  <pre><code>def d():
      print b
  def a():
      b = [1,2,3]
      d()
  
  a()
  </code></pre>
  
  <p>error:</p>
  
  <pre><code>  File "c.py", line 21, in &lt;module&gt;
      a()
    File "c.py", line 19, in a
      d()
    File "c.py", line 16, in d
      print b
  NameError: global name 'b' is not defined
  </code></pre>
  
  <p>so i have many different Variable, like b in different functions , so i don't want to send Variable like this :</p>
  
  <pre><code>def d(b1,b2,b3,b4,b5):
      print b1,b2,b3,b4,b5
  </code></pre>
  
  <p>that is not very simple , so i do it like this :</p>
  
  <pre><code>d = \
  '''
  def d():\n
      print b
  '''
  def a():
      b = [1,2,3]
      c = eval(d)
      c()
  
  a() 
  </code></pre>
  
  <p>but it also show error:</p>
  
  <pre><code>  File "c.py", line 16, in &lt;module&gt;
      a()
    File "c.py", line 13, in a
      c = eval(d)
    File "&lt;string&gt;", line 2
      def d():
        ^
  </code></pre>
  
  <p>so what can i do ,</p>
  
  <p>thanks</p>