On Sunday, January 18, 2015 at 8:09:00 AM UTC-8, Jernej Azarija wrote:
>
>
>
> On Sun, Jan 18, 2015 at 5:02 PM, Dima Pasechnik <[email protected] 
> <javascript:>> wrote:
>
>> On 2015-01-18, Jernej Azarija <[email protected] <javascript:>> wrote:
>> > The thing is that sys.exit works pretty much the same way
>> >
>> >====
>> > azi@goodegg:~$ cat foo.sage
>> > import sys
>> > sys.exit(42)
>> > azi@goodegg:~$ sage foo.sage
>> > 42
>> > azi@goodegg:~$ echo $?
>> > 1
>> >====
>> >
>> > And the print itself is extremely annoying. I need to call Sage 10^6 
>> times
>> > from an external program and get 10^6 lines of non-needed output.
>>
>> this looks pretty bad, given that Sage's startup+exit time is 1 or 2 
>> seconds
>> on a reasoably fast computer.
>> (unless your computations are still much slower, of course).
>>
>> There should be ways to communicate with Sage without quitting in.
>>
> I agree. I ended up writing the output to a file and parsing it within the 
> caller. Still pretty  ugly and inefficient but it works.
>
> Though this still does not answer the question - why is Sage printing the 
> exit status and not conforming to the standard behaviour of unix programs?
>


Oh, I see: it's the preparsing. When you do "sys.exit(42)", the number 42 
is a Sage integer, not a Python integer. So sys.exit doesn't know what to 
do with it. (I still don't know why that causes the number to be printed.)

So use sys.exit(int(42)) instead.

-- 
You received this message because you are subscribed to the Google Groups 
"sage-devel" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sage-devel.
For more options, visit https://groups.google.com/d/optout.

Reply via email to