First time here? Check out the FAQ!

Ask Your Question
1

Call pure python code from SAGE

asked 12 years ago

kankamuso gravatar image

updated 12 years ago

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!

Preview: (hide)

Comments

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

kcrisman gravatar imagekcrisman ( 12 years ago )

1 Answer

Sort by » oldest newest most voted
5

answered 12 years ago

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.

Preview: (hide)
link

Comments

1

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

alejandroerickson gravatar imagealejandroerickson ( 12 years ago )

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 ( 12 years ago )

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: 12 years ago

Seen: 717 times

Last updated: May 09 '12