Ask Your Question
1

Call pure python code from SAGE

asked 2012-04-30 12:23:18 +0200

kankamuso gravatar image

updated 2012-05-09 18:46:49 +0200

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 13:45:03 +0200 )edit

1 Answer

Sort by ยป oldest newest most voted
5

answered 2012-04-30 19:41:01 +0200

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-05-01 01:22:51 +0200 )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 23:27:08 +0200 )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 12:23:18 +0200

Seen: 629 times

Last updated: May 09 '12