On 2015-01-18, Jernej Azarija <azi.std...@gmail.com> 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.
>
>
> On Sat, Jan 17, 2015 at 11:24 PM, Robert Bradshaw <
> rober...@math.washington.edu> wrote:
>
>> On Sat, Jan 17, 2015 at 2:02 PM, John H Palmieri <jhpalmier...@gmail.com>
>> wrote:
>> >
>> >
>> > On Saturday, January 17, 2015 at 10:28:22 AM UTC-8, Jernej Azarija wrote:
>> >>
>> >> Hello,
>> >>
>> >> I have to use Sage from an external comand and in order to do so I'll
>> need
>> >> to rely on the exit status given by Sage. Considering a trivial example
>> >>
>> >> =============
>> >> $ cat foo.sage
>> >> exit(0)
>> >> =============
>> >>
>> >>
>> >> I get the following behaviour
>> >>
>> >>
>> >> =============
>> >> $ sage la.sage
>> >> 0
>> >> $ echo $?
>> >> 1
>> >> =============
>> >>
>> >> There are two things I am confused with here.
>> >>
>> >> 1. Why do we print 0?
>> >>
>> >>
>> >> 2. Why is the exit status 1 - indicating an error by UNIX standards?
>> >>
>> >>
>> >> Is there any reason behind this? If yes , what would be the best way to
>> >> force my own exit status so that I can interpret the execution of Sage
>> from
>> >> an external program?
>> >
>> >
>> > The underlying problem is that the "exit" function in Python doesn't
>> accept
>> > any arguments, so "exit(0)" raises an error when you run it in Sage.
>> This is
>> > why the exit status is nonzero. If your script had the line "exit()", it
>> > would run as expected. Given that, I'm not sure why it prints 0. If you
>> do
>> > "exit(3)", it will print 3 instead.
>>
>> You probably want sys.exit, which does take an exit status as an integer.
>>
>> --
>> You received this message because you are subscribed to a topic in the
>> Google Groups "sage-devel" group.
>> To unsubscribe from this topic, visit
>> https://groups.google.com/d/topic/sage-devel/CriQpiwWRLA/unsubscribe.
>> To unsubscribe from this group and all its topics, send an email to
>> sage-devel+unsubscr...@googlegroups.com.
>> To post to this group, send email to sage-devel@googlegroups.com.
>> Visit this group at http://groups.google.com/group/sage-devel.
>> For more options, visit https://groups.google.com/d/optout.
>>
>

-- 
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 sage-devel+unsubscr...@googlegroups.com.
To post to this group, send email to sage-devel@googlegroups.com.
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