ASKSAGE: Sage Q&A Forum - RSS feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Thu, 27 Sep 2012 15:00:33 +0200Why would someone use .sage vs .py?https://ask.sagemath.org/question/9354/why-would-someone-use-sage-vs-py/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?Thu, 27 Sep 2012 00:37:21 +0200https://ask.sagemath.org/question/9354/why-would-someone-use-sage-vs-py/Answer by Dima for <p>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?</p>
https://ask.sagemath.org/question/9354/why-would-someone-use-sage-vs-py/?answer=14069#post-id-14069Sage 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!Thu, 27 Sep 2012 10:21:54 +0200https://ask.sagemath.org/question/9354/why-would-someone-use-sage-vs-py/?answer=14069#post-id-14069Comment by kcrisman for <p>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.</p>
<p>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!</p>
https://ask.sagemath.org/question/9354/why-would-someone-use-sage-vs-py/?comment=19001#post-id-19001Though I think the poster is wondering about writing things that could use Sage but as .py files, perhaps?Thu, 27 Sep 2012 13:03:03 +0200https://ask.sagemath.org/question/9354/why-would-someone-use-sage-vs-py/?comment=19001#post-id-19001Comment by kcrisman for <p>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.</p>
<p>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!</p>
https://ask.sagemath.org/question/9354/why-would-someone-use-sage-vs-py/?comment=18995#post-id-18995@SLOtoSF: Also, Sage files CAN do everything Python files do, if you turn off the preparser - see the full answer to the question you reference.Thu, 27 Sep 2012 14:42:54 +0200https://ask.sagemath.org/question/9354/why-would-someone-use-sage-vs-py/?comment=18995#post-id-18995Comment by kcrisman for <p>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.</p>
<p>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!</p>
https://ask.sagemath.org/question/9354/why-would-someone-use-sage-vs-py/?comment=18996#post-id-18996Again, 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.Thu, 27 Sep 2012 14:41:21 +0200https://ask.sagemath.org/question/9354/why-would-someone-use-sage-vs-py/?comment=18996#post-id-18996Comment by SLOtoSF for <p>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.</p>
<p>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!</p>
https://ask.sagemath.org/question/9354/why-would-someone-use-sage-vs-py/?comment=18993#post-id-18993@kcrisman Thanks so much for your help. I am writing it this way because I think this can become at least an optional package. Regarding `load` or `attach`, those commands work, but when I had a load command within a file which i loaded, those didn't work.... but that's this question: http://ask.sagemath.org/question/1795/opening-sage-files-within-other-files . Ultimately this is why I went this import route.Thu, 27 Sep 2012 15:00:33 +0200https://ask.sagemath.org/question/9354/why-would-someone-use-sage-vs-py/?comment=18993#post-id-18993Comment by SLOtoSF for <p>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.</p>
<p>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!</p>
https://ask.sagemath.org/question/9354/why-would-someone-use-sage-vs-py/?comment=18997#post-id-18997Also 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.Thu, 27 Sep 2012 14:28:19 +0200https://ask.sagemath.org/question/9354/why-would-someone-use-sage-vs-py/?comment=18997#post-id-18997Comment by SLOtoSF for <p>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.</p>
<p>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!</p>
https://ask.sagemath.org/question/9354/why-would-someone-use-sage-vs-py/?comment=18999#post-id-18999To 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-inThu, 27 Sep 2012 14:00:14 +0200https://ask.sagemath.org/question/9354/why-would-someone-use-sage-vs-py/?comment=18999#post-id-18999Comment by SLOtoSF for <p>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.</p>
<p>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!</p>
https://ask.sagemath.org/question/9354/why-would-someone-use-sage-vs-py/?comment=19000#post-id-19000Yes, 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.Thu, 27 Sep 2012 13:42:59 +0200https://ask.sagemath.org/question/9354/why-would-someone-use-sage-vs-py/?comment=19000#post-id-19000