Silent python program

D-Man dsh8290 at rit.edu
Wed May 30 22:32:05 EDT 2001


On Wed, May 30, 2001 at 09:24:33PM -0400, Andreas Jung wrote:
| 
| <olav.viken at kmss.no> schrieb im Newsbeitrag
| news:9f04gg$6sj$1 at oslo-nntp.eunet.no...
| > Can anyone tell me how to make a python script "silent" on win32 platform,
| > as it was running in the background.  I don't want any output to the
| > screen.
| 
| What about  the following ?
| 
| import sys
| sys.stdout=sys.stderr=None

The "DOS box" will still be displayed.  Surprisingly enough I didn't
get a stack trace saying that "Object 'Non' has no 'write' attribute",
but then again the stack trace would b e sent to sys.stderr (None).

What Olav wants is to name his "main" script with the extension .pyw
instead of .py and the DOS box won't appear.  (It will use the
'pythonw' binary executable instead of 'python')

-D





More information about the Python-list mailing list