title: True dynamic and anonymous functions possible in Python?
body: <p>Just as a dynamic class can be created using  type(name, base-classes, namespace-dict), can a dynamic function be created?</p>
  
  <p>I've tried doing something along the lines of:</p>
  
  <pre><code>&gt;&gt;&gt; f = type("f", (function,), {})
  NameError: name 'function' is not defined
  </code></pre>
  
  <p>Ok, so I'll be clever, but:</p>
  
  <pre><code>&gt;&gt;&gt; def fn():
  ...   pass
  ... 
  &gt;&gt;&gt; type(fn)
  &lt;type 'function'&gt;
  &gt;&gt;&gt; f = type("f", (type(fn),), {})
  Traceback (most recent call last):
    File "&lt;stdin&gt;", line 1, in &lt;module&gt;
  TypeError: type 'function' is not an acceptable base type
  </code></pre>
  
  <p>Does Python <em>specifically</em> prevent the creation of dynamic functions in the same way it allows dynamic classes?</p>
  
  <p>Edit: Note, I'd disallow any use of exec.. Since my question is does the Python language itself permit this.</p>
  
  <p>Thanks in advance.</p>