Re: Detecting -i in a script

2009-04-13 Thread Christian Heimes
Marek Szuba wrote: > Is there any way of detecting in a script whether the interpreter > session running it has been launched with the -i option? My Google fu > has failed me on this subject... Thanks in advance. There is no direct way to detect the interactive flag. However sys.ps1 and sys.ps2 ar

Re: Detecting -i in a script

2009-04-13 Thread Chris Rebert
On Mon, Apr 13, 2009 at 6:10 PM, Static Vagabond wrote: > Chris Rebert wrote: >>> >>> Marek Szuba wrote: On 2009-04-13, Chris Rebert wrote: > The sys.flags.interactive bool. > > Details: http://docs.python.org/library/sys.html#sys.flags Hmm, "New in version 2.

Re: Detecting -i in a script

2009-04-13 Thread Static Vagabond
Chris Rebert wrote: Marek Szuba wrote: On 2009-04-13, Chris Rebert wrote: The sys.flags.interactive bool. Details: http://docs.python.org/library/sys.html#sys.flags Hmm, "New in version 2.6"... Are you aware of any way of extracting this information in older versions of Python? My code need

Re: Detecting -i in a script

2009-04-13 Thread Chris Rebert
> Marek Szuba wrote: >> >> On 2009-04-13, Chris Rebert wrote: >> >>> The sys.flags.interactive bool. >>> >>> Details: http://docs.python.org/library/sys.html#sys.flags >> >> Hmm, "New in version 2.6"... Are you aware of any way of extracting >> this information in older versions of Python? My code

Re: Detecting -i in a script

2009-04-13 Thread Static Vagabond
I think getopt will help you achieve what you need. http://docs.python.org/library/getopt.html Here's a quick example: import getopt import sys try: opts, args = getopt.getopt(sys.argv[1:], "-i:vo:vhb?") except getopt.GetoptError, err: helpCommand() # defined elsewhere. sys.exit()

Re: Detecting -i in a script

2009-04-13 Thread Marek Szuba
On 2009-04-13, Chris Rebert wrote: > The sys.flags.interactive bool. > > Details: http://docs.python.org/library/sys.html#sys.flags Hmm, "New in version 2.6"... Are you aware of any way of extracting this information in older versions of Python? My code needs to be 2.3-compatible. -- MS -- http

Re: Detecting -i in a script

2009-04-13 Thread Chris Rebert
On Mon, Apr 13, 2009 at 12:09 PM, Marek Szuba wrote: > Hello there, > > Is there any way of detecting in a script whether the interpreter > session running it has been launched with the -i option? My Google fu > has failed me on this subject... Thanks in advance. The sys.flags.interactive bool.