#8478: Programming tutorial page seems incorrect
---------------------------------+------------------------------------------
       Reporter:  lesshaste      |         Owner:  mvngu
           Type:  defect         |        Status:  new  
       Priority:  major          |     Milestone:       
      Component:  documentation  |    Resolution:       
       Keywords:                 |   Work issues:       
Report Upstream:  N/A            |     Reviewers:       
        Authors:                 |     Merged in:       
   Dependencies:                 |      Stopgaps:       
---------------------------------+------------------------------------------
Description changed by edgimar:

Old description:

> The section Standalone Python/Sage Scripts at
> http://www.sagemath.org/doc/tutorial/programming.html#section-loadattach
> seems to have two problems (profuse apologies if these are actually user
> errors).
>
> 1) #!/usr/bin/env sage -python   doesn't work in linux as shebang can't
> take two arguments. One simple workaround is to use #!/path_to_sage
> -python
> 2) The script itself seems broken. Testing it using sage 4.3.3
>
> ./factor 2006
>
> works as expected.
>
> But ./factor "32*x^5-1"  gives
> Traceback (most recent call last):
>   File "./factor", line 11, in <module>
>     print factor(sage_eval(sys.argv[1]))
>   File "/opt/sage-4.3.3-linux-32bit-
> ubuntu_9.10-i686-Linux/local/lib/python2.6/site-
> packages/sage/misc/sage_eval.py", line 199, in sage_eval
>     return eval(source, sage.all.__dict__, locals)
>   File "<string>", line 1, in <module>
> NameError: name 'x' is not defined

New description:

 The section Standalone !Python/Sage Scripts at
 http://www.sagemath.org/doc/tutorial/programming.html#section-loadattach
 seems to have two problems (profuse apologies if these are actually user
 errors).

 1. __`#!/usr/bin/env sage -python`__ doesn't work in linux since a shebang
 line can only handle a single argument ('sage' in this case). One
 workaround is to use __`#!/path/to/sage -python`__ -- I have since
 verified, however, that simply using __`#!/usr/bin/env sage`__ **does**
 work with sage 5.8.
 2. The script itself seems broken.  When testing it using sage 4.3.3 (and
 5.8), running __`./factor 2006`__ works as expected, but __`./factor
 "32*x^5-1"`__ gives:

 {{{
 Traceback (most recent call last):
   File "./factor", line 11, in <module>
     print factor(sage_eval(sys.argv[1]))
   File "/opt/sage-4.3.3-linux-32bit-
 ubuntu_9.10-i686-Linux/local/lib/python2.6/site-
 packages/sage/misc/sage_eval.py", line 199, in sage_eval
     return eval(source, sage.all.__dict__, locals)
   File "<string>", line 1, in <module>
 NameError: name 'x' is not defined
 }}}

 To correct this, see the comment attached to this ticket which provides a
 new version of the 'factor' script.

--

-- 
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/8478#comment:3>
Sage <http://www.sagemath.org>
Sage: Creating a Viable Open Source Alternative to Magma, Maple, Mathematica, 
and MATLAB

-- 
You received this message because you are subscribed to the Google Groups 
"sage-trac" 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-trac.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to