First time here? Check out the FAQ!

Ask Your Question
1

Why would someone use .sage vs .py?

asked 12 years ago

SLOtoSF gravatar image

updated 12 years ago

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?

Preview: (hide)

1 Answer

Sort by » oldest newest most voted
2

answered 12 years ago

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!

Preview: (hide)
link

Comments

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

kcrisman gravatar imagekcrisman ( 12 years ago )

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 ( 12 years ago )

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 ( 12 years ago )

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 ( 12 years ago )

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 ( 12 years ago )

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: 12 years ago

Seen: 855 times

Last updated: Sep 27 '12