semantics of __module__
<p>I'm dynamically defining functions in a module and then updating the module's <code>__all__</code> and the function's <code>__name__</code> attribute to match the name it will have inside the module.  I was wondering if it is a good idea to update the function's <code>__module__</code> attribute as well to point to the module the function will reside.  The docs say <code>__module__</code> is:</p>

<blockquote>
  <p>The name of the module the function was defined in, or None if unavailable.</p>
</blockquote>

<p>The code that creates the function resides in a different module which is pretty much unrelated to the module where the function resides.  There is no reference to the function in this module.</p>

<p>I've done some poking around on the mailing list but I'm a bit confused as to what the semantics of <code>__module__</code> are and if I should set it to None or the module that the function resides or the module where the code resides that created the function.  Gonna leave it be for now but am interested to see if anyone knows the answer.</p>
