Re: How a script can know if it has been called with the -i command line option?



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
.



Relevant Pages

  • Re: Access Denied (was Moving a file corrupts it)
    ... > When I wish to move a file from one folder to another, I usually use the> right click>cut>paste mouse command. ... > go to retrieve the file in its new location, I receive messages similar to> those listed by Mike. ... > My assumption is that there is a problem with Windows, rather than a> specific program. ...
    (microsoft.public.windowsxp.general)
  • Access Denied (was Moving a file corrupts it)
    ... I am having a problem similar to the one Mike posted a few weeks ago. ... I get the same result when I use the edit>cut>paste command. ... I use the command right click>copy>paste, I can retrieve the file in its new ... specific program (I have Windows XPSP2). ...
    (microsoft.public.windowsxp.general)
  • RE: Access Denied problems; (was Moving a file corrupts it)
    ... I am having a problem similar to the one Mike posted a few weeks ago. ... I get the same result when I use the edit>cut>paste command. ... I use the command right click>copy>paste, I can retrieve the file in its new ... specific program (I have Windows XPSP2). ...
    (microsoft.public.windowsxp.general)
  • Re: How a script can know if it has been called with the -i command lineoption?
    ... but I don't see a way to retrieve the command line flags, ... not the options passed to the script. ...
    (comp.lang.python)
  • Re: How a script can know if it has been called with the -i command line option?
    ... Michele Simionato schrieb: ... but I don't see a way to retrieve the command line flags, ... I don't know how to get the command line flags, but the variable you are interested ...
    (comp.lang.python)