Detect PythonWin?
logistix at cathoderaymission.net
logistix at cathoderaymission.net
Fri Aug 1 11:29:29 EDT 2003
Martin Bless <m.bless at gmx.de> wrote in message news:<ejfkivo0ah8me65ge5o7pptj3v6dcq1sfo at 4ax.com>...
> [Andrew Dalke]:
>
> >To see if you're on Windows,
> [...]
> >To see if the win32 extensions are installed
>
> Ok,
> but how can my script know it its running from inside PythonWin?
>
> I often have the situation that while developing with PythonWin I have
> to insert code like
>
> if 1 and "developing in PythonWin":
> sys.argv[1:] = ['fake', 'arguments']
>
> Later on or when running the same script from the commandline I need
> to disable this if statement. Nasty.
>
> I'm looking for a predicate functions that will let my script know if
> it's running from inside PythonWin. And the function shouldn't use
> much time or resources if we are not in PythonWin.
>
> Anybody knows?
>
> Martin
>>> import sys
>>> if sys.modules.has_key('pywin'):
... print "pythonwin running"
... else:
... print "pythonwin not running"
...
pythonwin running
>>>
This shouldn't have any overhead. Writing a predicate function is
left as an exercise to the reader.
More information about the Python-list
mailing list