Stop Python from exiting upon error in Windows
Peter Hansen
peter at engcorp.com
Tue Jul 15 12:26:57 EDT 2003
Robert at AbilitySys.com wrote:
>
> Ok, I figured out the IDLE block indent (duh - RTFMenu), and now it works
> great in DOS. Again, thanks to all who helped.
>
> However, I'd still like to know how to determine what environment I'm
> running under inside my code. Any suggestions?
I doubt if there's any particular way to do it consistently. In
principle one could write a cute module which would be able to check
the "signature" of the environment to figure it all out. Check if
certain modules are in __builtins__ to see if you are running inside
an application that uses Python for scripting, check for sys.argv[0]
to learn whether you were launched in a way that suggests running as
a script with python.exe, etc.
It's probably not a great idea to write anything which depends on this
however, and it sounds like more time than it's worth.
-Peter
More information about the Python-list
mailing list