Windows: How to detect whether a Python app/script is running in console/GUI mode?

Brian Curtin brian.curtin at gmail.com
Tue Jul 27 10:58:13 EDT 2010


On Tue, Jul 27, 2010 at 09:36, <python at bdurham.com> wrote:

> Windows: How can I detect whether a Python app/script is running in
> console/GUI mode? By app I mean a script compiled to an exe via py2exe or
> similar.
>
> Thank you,
> Malcolm
>

I don't remember much about py2exe, but you could check if
``os.path.split(sys.executable)[1]`` equals pythonw.exe (typical for GUIs)
or just python.exe (regular console).
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20100727/a0291107/attachment-0001.html>


More information about the Python-list mailing list