On Nov 13, 10:28 am, hetchkay <hetch...@gmail.com> wrote: > On Nov 13, 9:50 am, John Yeung <gallium.arsen...@gmail.com> wrote: > > > > > On Nov 12, 11:22 pm, r <rt8...@gmail.com> wrote: > > > > On Nov 12, 10:07 pm, hetchkay <hetch...@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". > > > > Look here ;-) > > >http://docs.python.org/library/exceptions.html#exceptions.SystemExit > > > How does that answer the OP's question? Namely, how to make 2.6 > > behave like 2.5? (Even saying "You can't make 2.6 behave like 2.5" > > would have been a better answer.) > > > Failing that, how about something that explains why 2.6 behaves > > differently than 2.5, and why one of them is better or more correct > > than the other? > > > Personally, I think 2.6's is probably the more correct behavior. > > Specifically, if the point of the -i command line option is to force > > interactive mode after completion of the script (which in this case > > completed with sys.exit), then it should go to interactive mode > > regardless of whether the script terminates "normally" or not. I > > think 2.5's behavior of allowing interactive mode to be skipped is > > against the spirit of -i. Unless -i meant something different in 2.5. > > > Is there some kind of environment variable to set up to control this? > > > John > > I can understand the behavior from a '-i' point of view. My > requirement is somewhat different. Consider a geometry tool that can > be used to create objects, merge objects etc. I have python 'commands' > for doing any of these operations and for saving the objects to a > file. The user could write a file containing a set of commands (in > python format) and load this file in the GUI. Optionally, one of the > commands could be to exit in which case the GUI should shut down. I am > using 'execfile' to execute the file, and this does not exit if the > user has used sys.exit (or even if I expose a command called 'Exit' > which calls sys.exit). > > May be I should not be using execfile but I am not sure what else I > should use. The user-written file could contain loops and other > constructs as well. > > -Krishnan
Hi, I had been starting my application with -i option. I have removed this now and made a few other changes and things work OK now. Thanks to everyone who helped in this. Regards, Krishnan -- http://mail.python.org/mailman/listinfo/python-list