1 | initial version |

Import, load or run your code and fix each problem as it comes.

Regarding missing imports, use the `import_statements`

function.

```
sage: import_statements(var)
from sage.calculus.var import var
sage: import_statements(exists)
from sage.misc.misc import exists
sage: import_statements(forall)
from sage.misc.misc import forall
sage: import_statements(DiGraph)
from sage.graphs.digraph import DiGraph
```

2 | No.2 Revision |

Import, load or run your code and fix each problem as it comes.

Regarding missing imports, use the `import_statements`

function.

```
sage: import_statements(var)
from sage.calculus.var import var
sage: import_statements(exists)
from sage.misc.misc import exists
sage: import_statements(forall)
from sage.misc.misc import forall
sage: import_statements(DiGraph)
from sage.graphs.digraph import DiGraph
```

This will make the code run in Python with access to the Sage library.

If you want to remove access to the Sage library, it's different.

Look into `all`

and `any`

to replace use of `forall`

and `exists`

.

Regarding `var`

, SymPy certainly has similar functionality,
and would be lighter than Sage.

Regarding graphs, see what graph libraries have the functionality you need.

3 | No.3 Revision |

To sum up the question: we have a file `myfile.sage`

and the question is to turn it into a `myfile.py`

file.

The automatic way is to run in the terminal:

```
$ sage --preparse myfile.sage
```

which will produce a file `myfile.sage.py`

that is a preparsed version of the original file.

In terms of imports, it adds the following import:

```
from sage.all_cmdline import * # import sage library
```

Import, ~~load or ~~load, run your code and fix each problem as it comes.

Regarding missing imports, use the `import_statements`

function.

```
sage: import_statements(var)
from sage.calculus.var import var
sage: import_statements(exists)
from sage.misc.misc import exists
sage: import_statements(forall)
from sage.misc.misc import forall
sage: import_statements(DiGraph)
from sage.graphs.digraph import DiGraph
```

This will give minimal imports that make the code run in Python ~~with ~~(with access to the Sage ~~library.~~library).

If you want to remove access to the Sage library, it's different.

Look into `all`

and `any`

to replace use of `forall`

and `exists`

.

Regarding `var`

, SymPy certainly has similar functionality,
and would be lighter than Sage.

Regarding graphs, see what graph libraries have the functionality you need.

Copyright Sage, 2010. Some rights reserved under creative commons license. Content on this site is licensed under a Creative Commons Attribution Share Alike 3.0 license.