 <p>This isn't something you should normally be doing just to save a little typing, but here's one way you can do it:</p> <pre><code># define some constants PI = 3.1415927 ANSWER = 42 UNLUCKY = 13 # put them into __main__ module (your interactive session) if __name__ != "__main__": import sys as _sys _sys.modules["__main__"].__dict__.update( dict((k, v) for (k, v) in globals().iteritems() if not k.startswith("_"))) </code></pre>