How can I get the name/file of the script from sitecustomize.py?
<p>When I run any Python script, I would like to see the script's filename appear in the Windows command line window's titlebar. For example, if I run a script called "<code>mytest.py</code>", I want to see "<code>mytest</code>" in the titlebar. I would like this to be automatic, so I don't have to add code to every one of my scripts.</p>

<p>Currently I'm attempting to do this with <code>sitecustomize.py</code>, because when Python is run, including from double-clicking a Python script, <code>sitecustomize</code> is imported before the script runs.</p>

<p>I've tried getting <code>__main__</code>'s <code>__file__</code> and <code>sys.argv</code>, but <code>sitecustomize</code> doesn't see either:</p>

<p>file <code>sitecustomize.py</code>:</p>

<pre><code>import __main__, sys
print "hasattr __main__.__file__:", hasattr(__main__, "__file__")
print "hasattr sys.argv:", hasattr(sys, "argv")
print "-" * 60
</code></pre>

<p>file <code>mytest.py</code>:</p>

<pre><code>import sys
print "__file__ is:", __file__
print "sys.argv is:", sys.argv
raw_input() # don't end the script immediately
</code></pre>

<p>output:</p>

<pre><code>hasattr __main__.__file__: False
hasattr sys.argv: False
------------------------------------------------------------
__file__ is: C:\Documents and Settings\Owner\Desktop\mytest.py
sys.argv is: ['C:\\Documents and Settings\\Owner\\Desktop\\mytest.py']
</code></pre>
