title: Using multiple functions in Python 3 map()
body: <p>I'm not sure why the code below works. According to docs, map only takes one function as the first argument and applies it to one or more iterables, depending on how many parameters the function takes.</p>
  
  <p><code>map(function, iterable..)</code></p>
  
  <p>However, in place of iterables, you can pass multiple functions and somehow they are treated as iterables. Somehow this line is taking the functions add, square and str and treating them as iterables. </p>
  
  <p>How are functions being considered valid iterables?</p>
  
  <pre class="lang-py prettyprint-override"><code>def add(x):
      return x + x
  
  
  def square(x):
      return x * x
  
  
  nums = [1, 2, 3, 4, 5]
  
  for i in nums:
      vals = list(map(lambda x: x(i), (add, square, str)))
  
      print(vals)
  </code></pre>
  
  <p>returns:</p>
  
  <pre><code>[2, 1, '1']
  [4, 4, '2']
  [6, 9, '3']
  [8, 16, '4']
  [10, 25, '5']
  </code></pre>
  
  <p>*EDIT
  Martijn answered the question. This code does the same thing but breaks it out of the lambda function showing how <code>add, square, str</code> are functions being iterated upon.</p>
  
  <pre class="lang-py prettyprint-override"><code>def add(x):
      return x + x
  
  
  def square(x):
      return x * x
  
  
  def act_on_iter(iter_obj, i):
      return iter_obj(i)
  
  
  nums = [1, 2, 3, 4, 5]
  
  for i in nums:
      vals = list(map(act_on_iter, (add, square, str), [i] * 3))
  
      print(vals)
  </code></pre>
  
  <p>returns the same</p>
  
  <pre><code>[2, 1, '1']
  [4, 4, '2']
  [6, 9, '3']
  [8, 16, '4']
  [10, 25, '5']
  </code></pre>