> I'm learning to use Sage/Python for undergrad research over this > summer. I'm running Sage 4.4.2 (binary build) on snow leopard (Mac OS > 10.6.3). I wrote an extremely small program in python: > > import sys > from sage.all import * > > print "Hello" > > and called it test.py. It is currently in my sage folder. I type > test.py into the command line and get the error: > > NameError Traceback (most recent call > last) > > /Applications/sage/<ipython console> in <module>() > > NameError: name 'test' is not defined
Hi, I'm also a new sage user, but one way to get started is to read: http://www.sagemath.org/doc/tutorial/programming.html#section-standalone To get your script to run, you could type: <path to sage executable>/sage test.py at any command shell (bash, sh, etc). If you add the sage installation directory to your PATH environment variable, then you could simply call "sage test.py". Note that using a ".py" extension would disable the sage pre-parser, so the expression "2^8" in the script would not be interpreted as exponentiation (as in sage), but as the bitwise-or operator as defined in python (I believe). To run a script using the sage pre-parser, use a ".sage" extension. There's probably other variations of the same idea here, but I usually use the Sage Notebook, so I don't know much about running external scripts. -- Tianwei. -- To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/sage-support URL: http://www.sagemath.org
