Re: How a script can know if it has been called with the -i command line option?
- From: "Michael B. Trausch" <michael.trausch@xxxxxxxxxxx>
- Date: Fri, 22 Dec 2006 12:03:56 -0500
Peter Wang wrote:
Michele Simionato wrote:The subject says it all, I would like a script to act differently when
called as
$ python script.py and when called as $ python -i script.py. I looked
at the sys module
but I don't see a way to retrieve the command line flags, where should
I look?
I realize this is quite a hack, but the entire command line is
preserved in the process's entry in the OS's process table. if you do
"ps -ax" you will see that the interpreter was invoked with -i. I
didn't test this under windows, but it works on Mac and Linux.
There is a set of utilities that have UNIX-like ps behavior, but, as is typical for Windows, they don't work the way their UNIX and UNIX-like counterparts do. Does 'ps' work from within Cygwin, and if so, would redistributing that be an option?
-- Mike
.
- Follow-Ups:
- References:
- How a script can know if it has been called with the -i command line option?
- From: Michele Simionato
- Re: How a script can know if it has been called with the -i command line option?
- From: Peter Wang
- How a script can know if it has been called with the -i command line option?
- Prev by Date: Re: How a script can know if it has been called with the -i command line option?
- Next by Date: Re: Decorator for Enforcing Argument Types
- Previous by thread: Re: How a script can know if it has been called with the -i command line option?
- Next by thread: Re: How a script can know if it has been called with the -i command line option?
- Index(es):
Relevant Pages
|