Ask Your Question
1

Call pure python code from SAGE

asked 2012-04-30 05:23:18 -0500

kankamuso gravatar image

updated 2012-05-09 11:46:49 -0500

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!

edit retag flag offensive close merge delete

Comments

Short answer is yes. Are you looking for this in the notebook or command line?

kcrisman gravatar imagekcrisman ( 2012-04-30 06:45:03 -0500 )edit

1 answer

Sort by ยป oldest newest most voted
5

answered 2012-04-30 12:41:01 -0500

Jason Grout gravatar image

Here 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.

edit flag offensive delete link more

Comments

1

What about some pure python in the interpreter? i'm using sage interpreter in emacs...

alejandroerickson gravatar imagealejandroerickson ( 2012-04-30 18:22:51 -0500 )edit

The 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.

Jason Grout gravatar imageJason Grout ( 2012-05-10 16:27:08 -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-04-30 05:23:18 -0500

Seen: 328 times

Last updated: May 09 '12