Ask Your Question
1

Why would someone use .sage vs .py?

asked 2012-09-26 17:37:21 -0500

SLOtoSF gravatar image

updated 2012-09-27 02:12:40 -0500

kcrisman gravatar image

Why would someone use .sage vs .py? What's recommended? What are the pros and cons? There are questions people ask like: "This can be done in Sage but I can't do it in my python file?" Why would they do anything in python if they could just do it in Sage?

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
2

answered 2012-09-27 03:21:54 -0500

Sage is a (very, very big) python library, and it does not (natively) run on Windowz. "Pure" python is smaller, much more lightweight and easier to install and run.

Just in case, note that .sage and .py are file extensions. In fact, Sage internally "preparses" every .sage file and converts it into .py file. So in particular, if you have a file named f.sage, then do not keep a file named f.py in the same directory, as Sage would overwrite it!

edit flag offensive delete link more

Comments

Though I think the poster is wondering about writing things that could use Sage but as .py files, perhaps?

kcrisman gravatar imagekcrisman ( 2012-09-27 06:03:03 -0500 )edit

Yes, I am looking for more of a qualitative analysis. The Developer's Guide gives the example of creating new directories and storing python files. Why would it do so if .sage files work just as well without the added issue of importing modules? Is it possible that the Python files can be reused elsewhere? I know that in different situations there is more than one way to solve a problem, I'm wondering why I would ever do things with .py files.

SLOtoSF gravatar imageSLOtoSF ( 2012-09-27 06:42:59 -0500 )edit

To perhaps help with the response, here is a question which highlights something .sage files can't do, but .py files can: http://ask.sagemath.org/question/1520/python-thing-that-doesnt-work-in-sage-works-in

SLOtoSF gravatar imageSLOtoSF ( 2012-09-27 07:00:14 -0500 )edit

Also Dima, I tried to have a .sage file but sage wasn't registering the .sage file I was building it, even when i modified it. It seems for now I will use the blanket "from sage.all import *" statement at the top of each python file.

SLOtoSF gravatar imageSLOtoSF ( 2012-09-27 07:28:19 -0500 )edit

Again, use `load` or `attach`. Remember, the developer guide is for people intended to develop **new material inside of Sage**, not people developing their own other materials.

kcrisman gravatar imagekcrisman ( 2012-09-27 07:41:21 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

Stats

Asked: 2012-09-26 17:37:21 -0500

Seen: 283 times

Last updated: Sep 27 '12