Ask Your Question

Alexandre Martins's profile - activity

2016-08-17 00:54:32 +0200 received badge  Famous Question (source)
2016-07-27 09:31:47 +0200 received badge  Student (source)
2014-06-04 18:49:13 +0200 received badge  Notable Question (source)
2013-04-16 20:00:22 +0200 marked best answer How do I convert a notebook to a python script?

There are a couple of ways of doing this. You can write a pythonscript script and import the sage module. In order to use sage commands use the following line

from sage.all import *

In order to do this you need sage in you PYHTONPATH. You can make sure it does by starting your python script with

import sys
sys.path.append('path-to-sage')

A better alternative, which I use when I am trying to do what you are doing, is that I write the python script with 'from sage.all import *' on the first line and then use the python from sage to run it using the command

sage -python

This way you can use the python interpreter of sage.

2013-04-16 20:00:22 +0200 received badge  Scholar (source)
2013-02-15 08:41:18 +0200 received badge  Popular Question (source)
2012-05-11 07:30:31 +0200 received badge  Organizer (source)
2012-05-11 07:29:16 +0200 commented question How do I convert a notebook to a python script?

Both answers here are very usefull to me. I'm just taking a bit of time selecting a "right" answer because I haven't tried them yet in a big project.

2012-05-11 07:27:17 +0200 commented answer How do I convert a notebook to a python script?

@EviatarBach This is actually a nice approach to what I was asking. Not a complete answer but I wasn't expecting that since what I ask is a bit outside sage's use cases.

2012-03-10 14:58:00 +0200 asked a question How do I convert a notebook to a python script?

I'm asking this because I'm starting a project and Sage seems like a very good platform to do some prototyping.

Better yet, it might be a great way to use the code that results from my prototyping directly has the final version as well.

But for that to work with a minimal of hardship though, a few things would be usefull:

  1. A way to grab the code content of a notebook and generate an independent python script or function

  2. A list of libraries, with version, that every sage version uses.

  3. An instalable library version of sage that could be imported from the script

  4. Anything else that I'm missing and you know sage can do to help in this task

I'm not asking for a completely automatic way to do this, just for resources/scripts or general advices about how to do it.

I'm also just starting to look into sage so, don't assume to much on what I may know. ;)

Thanks.

2012-03-07 21:51:09 +0200 received badge  Supporter (source)