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.Mon, 24 Jul 2017 21:44:26 +0200Suppress automatically generated Python files when running Sage scripthttps://ask.sagemath.org/question/38383/suppress-automatically-generated-python-files-when-running-sage-script/ Hello,
I'm curious if it is possible to stop Sage from automatically generating corresponding Python files. For instance, if I run a sage script `test.sage`, then after running `sage test.sage`, I'll get an automatically generated file called `test.sage.py`. Is there any way to suppress the generation of this file? I tried to take a look in the documentation, but I couldn't find anything.
Thanks again! Mon, 24 Jul 2017 20:44:17 +0200https://ask.sagemath.org/question/38383/suppress-automatically-generated-python-files-when-running-sage-script/Answer by vdelecroix for <p>Hello, </p>
<p>I'm curious if it is possible to stop Sage from automatically generating corresponding Python files. For instance, if I run a sage script <code>test.sage</code>, then after running <code>sage test.sage</code>, I'll get an automatically generated file called <code>test.sage.py</code>. Is there any way to suppress the generation of this file? I tried to take a look in the documentation, but I couldn't find anything. </p>
<p>Thanks again! </p>
https://ask.sagemath.org/question/38383/suppress-automatically-generated-python-files-when-running-sage-script/?answer=38388#post-id-38388You can not avoid it. The way it works is
1. Convert the `.sage` file into a `.py` file
2. Execute the `.py` file
If you don't want extra files to be created, just use `.py` files directly. The `.sage` hides some work for you. The conversion `.sage -> .py` essentially consists in
- writing the line `from sage.all import *` at the begining of the file
- turn on the [preparser](http://doc.sagemath.org/html/en/reference/repl/sage/repl/preparse.html). For example if you write `123` it will be understood as a Sage integer and not a Python integer.Mon, 24 Jul 2017 21:44:26 +0200https://ask.sagemath.org/question/38383/suppress-automatically-generated-python-files-when-running-sage-script/?answer=38388#post-id-38388