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, 10 May 2012 23:27:08 +0200Call pure python code from SAGEhttps://ask.sagemath.org/question/8938/call-pure-python-code-from-sage/Dear all,
I want to move from matlab for my image processing tasks. Nevertheless, to load the file formats I use (SPIDER, MRC, etc..), I only have some python code. Is it possible to directly invoke such python code from SAGE?. If so.. how? (I have looked for a Python inteface, but no luck for SAGE invoking Python). If not.. what is the recommended workflow to program and publish my codes for the community?.
Thanks in advance!Mon, 30 Apr 2012 12:23:18 +0200https://ask.sagemath.org/question/8938/call-pure-python-code-from-sage/Comment by kcrisman for <p>Dear all,</p>
<p>I want to move from matlab for my image processing tasks. Nevertheless, to load the file formats I use (SPIDER, MRC, etc..), I only have some python code. Is it possible to directly invoke such python code from SAGE?. If so.. how? (I have looked for a Python inteface, but no luck for SAGE invoking Python). If not.. what is the recommended workflow to program and publish my codes for the community?.</p>
<p>Thanks in advance!</p>
https://ask.sagemath.org/question/8938/call-pure-python-code-from-sage/?comment=19849#post-id-19849Short answer is yes. Are you looking for this in the notebook or command line?Mon, 30 Apr 2012 13:45:03 +0200https://ask.sagemath.org/question/8938/call-pure-python-code-from-sage/?comment=19849#post-id-19849Answer by Jason Grout for <p>Dear all,</p>
<p>I want to move from matlab for my image processing tasks. Nevertheless, to load the file formats I use (SPIDER, MRC, etc..), I only have some python code. Is it possible to directly invoke such python code from SAGE?. If so.. how? (I have looked for a Python inteface, but no luck for SAGE invoking Python). If not.. what is the recommended workflow to program and publish my codes for the community?.</p>
<p>Thanks in advance!</p>
https://ask.sagemath.org/question/8938/call-pure-python-code-from-sage/?answer=13515#post-id-13515Here are at least 3 ways:
* Run the code with `sage -python filename.py`
* In the notebook, choose "python" in the dropdown list at the top.
* In the notebook, put the code in a cell with a `%python` at the top of the cell.Mon, 30 Apr 2012 19:41:01 +0200https://ask.sagemath.org/question/8938/call-pure-python-code-from-sage/?answer=13515#post-id-13515Comment by alejandroerickson for <p>Here are at least 3 ways:</p>
<ul>
<li><p>Run the code with <code>sage -python filename.py</code></p></li>
<li><p>In the notebook, choose "python" in the dropdown list at the top.</p></li>
<li><p>In the notebook, put the code in a cell with a <code>%python</code> at the top of the cell.</p></li>
</ul>
https://ask.sagemath.org/question/8938/call-pure-python-code-from-sage/?comment=19842#post-id-19842What about some pure python in the interpreter? i'm using sage interpreter in emacs...Tue, 01 May 2012 01:22:51 +0200https://ask.sagemath.org/question/8938/call-pure-python-code-from-sage/?comment=19842#post-id-19842Comment by Jason Grout for <p>Here are at least 3 ways:</p>
<ul>
<li><p>Run the code with <code>sage -python filename.py</code></p></li>
<li><p>In the notebook, choose "python" in the dropdown list at the top.</p></li>
<li><p>In the notebook, put the code in a cell with a <code>%python</code> at the top of the cell.</p></li>
</ul>
https://ask.sagemath.org/question/8938/call-pure-python-code-from-sage/?comment=19791#post-id-19791The main difference is the preparser. You can turn off the preparser with `preparser(False)`. But I should also say---have you tried just running your code? Most python code runs just fine directly in Sage, even with the preparser on.Thu, 10 May 2012 23:27:08 +0200https://ask.sagemath.org/question/8938/call-pure-python-code-from-sage/?comment=19791#post-id-19791