[sage-support] Re: How do you stop sage in the middle of a block?

2013-03-05 Thread GaryMak
Hi - IT's most hopeless victim weighing in here I too would like a civilised way of exiting a loop; however if I implement os._exit(0) I get no output prior to the exit, no matter how much should have been printed by then ... for example the following program for ii in range(0,10):

Re: [sage-support] Re: How do you stop sage in the middle of a block?

2013-03-05 Thread William Stein
import sys; sys.stdout.flush() On Mar 5, 2013 4:49 AM, GaryMak garymako...@googlemail.com wrote: Hi - IT's most hopeless victim weighing in here I too would like a civilised way of exiting a loop; however if I implement os._exit(0) I get no output prior to the exit, no matter how much

Re: [sage-support] Re: How do you stop sage in the middle of a block?

2013-03-05 Thread Jeroen Demeyer
On 2013-03-05 13:49, GaryMak wrote: Hi - IT's most hopeless victim weighing in here I too would like a civilised way of exiting a loop; however if I implement os._exit(0) I get no output prior to the exit, no matter how much should have been printed by then ... Use sys.exit(0) instead

Re: [sage-support] Re: How do you stop sage in the middle of a block?

2013-03-05 Thread John Cremona
Are you sure that you really want to exit the program, and not just the loop? Try googling python loop break to see how to use the break keyword. John Cremona On 5 March 2013 14:54, Jeroen Demeyer jdeme...@cage.ugent.be wrote: On 2013-03-05 13:49, GaryMak wrote: Hi - IT's most hopeless victim

Re: [sage-support] Re: How do you stop sage in the middle of a block?

2013-03-05 Thread GaryMak
thanks William of course I didn't understand a thing - but it worked - only it runs the whole loop first - i need to exit when ii==6 in this example - but Jeroen's answer below is what I need best regards On Tuesday, March 5, 2013 2:50:06 PM UTC, William wrote: import sys;

Re: [sage-support] Re: How do you stop sage in the middle of a block?

2013-03-05 Thread GaryMak
thanks Jeroen - that's perfect - whatever it does!! On Tuesday, March 5, 2013 2:54:27 PM UTC, Jeroen Demeyer wrote: On 2013-03-05 13:49, GaryMak wrote: Hi - IT's most hopeless victim weighing in here I too would like a civilised way of exiting a loop; however if I implement

Re: [sage-support] Re: How do you stop sage in the middle of a block?

2013-03-05 Thread GaryMak
thanks John - yes - what I didn't explain was that I have several nested variables and i would like to exit the entire thing once I find an example of a certain behaviour - my previous workaround had been to set a flag on the innermost loop and then to check that flag at the end of each nesting

[sage-support] Re: How do you stop sage in the middle of a block?

2013-03-05 Thread GaryMak
Ah yes - my naiv-IT again ... one aspect I forgot to mention which William and Jeroen's solutions do not do (because I didn't ask them to) is to preserve the state of the variables i want to look at - so when I exit the loops, I need subsequently to work on the little creatures the code carries

[sage-support] Re: How do you stop sage in the middle of a block?

2012-11-20 Thread Volker Braun
sage: for m,n in CartesianProduct(range(2), range(3)): : p = 2*m : print p : if p==2: : m = 4 : break : if n==1: : os._exit(0) : 0 0 On Tuesday, November 20, 2012 6:48:14 PM UTC, LFS wrote: How do you get sage out of

[sage-support] Re: How do you stop sage in the middle of a block?

2012-11-20 Thread LFS
Thank-you both! The 'break' did what I wanted for now and will test os._exit() in a bit. Really appreciate your help. -- You received this message because you are subscribed to the Google Groups sage-support group. To post to this group, send email to sage-support@googlegroups.com. To

[sage-support] Re: How do you stop sage in the middle of a block?

2012-11-20 Thread Simon King
Hi! On 2012-11-20, LFS lfahlb...@gmail.com wrote: --=_Part_363_10202299.1353441032364 Content-Type: text/plain; charset=ISO-8859-1 Thank-you both! The 'break' did what I wanted for now and will test os._exit() in a bit. Really appreciate your help. PS: Sage's user language is Python