What are the different possible values for __name__ in a Python script, and what do they mean?
<p>Checking to see if <code>__name__ == '__main__'</code> is a common idiom to run some code when the file is being called directly, rather than through a module.</p>

<p>In the process of writing a custom command for Django's manage.py, I found myself needing to use <code>code.InteractiveConsole</code>, which gives the effect to the user of a standard python shell.  In some test code I was doing, I found that in the script I'm trying to execute, I get that <code>__name__</code> is <code>__console__</code>, which caused my code (dependent on <code>__main__</code>) to not run.</p>

<p>I'm fairly certain that I have some things in my original implementation to change, but it got me wondering as to what different things <code>__name__</code> could be.  I couldn't find any documentation on the possible values, nor what they mean, so that's how I ended up here.</p>
