2.6 and sys.exit()
Ned Deily
nad at acm.org
Fri Nov 13 00:10:32 EST 2009
In article
<008aa7ef-b945-4f70-b5e4-def66546eca2 at 2g2000prl.googlegroups.com>,
hetchkay <hetchkay at gmail.com> wrote:
> I have the following in exit.py:
> import sys
> sys.exit(0)
>
> I now try 'python -i exit.py':
>
> In 2.5, the script exits as I would expect.
>
> In 2.6, the following error is printed:
>
> Traceback (most recent call last):
> File "exit.py", line 2, in <module>
> sys.exit(0)
> SystemExit: 0
> >>>
>
> I couldn't find anything related to this in "What's new in 2.6".
>
> Is there any way I can get 2.6 to behave like 2.5?
Perhaps you don't want to be using the -i option?
"-i
When a script is passed as first argument or the -c option is used,
enter interactive mode after executing the script or the command ..."
http://docs.python.org/using/cmdline.html#generic-options
If you don't want the interpreter to gain control on exit, don't use -i
when you run the script.
--
Ned Deily,
nad at acm.org
More information about the Python-list
mailing list