# Revision history [back]

Here is a short recipe, assuming that your file is named your_file.sage:

From a standard terminal, type sage -sh. Within this new shell, whose path contains the sage scripts directory, type:

sage-preparse your_file.sage


A file named your_file.sage.py will appear.

Edit it and remove (or comment) the from sage.all_cmdline import * statement.

Now, install pyflakes for Python 2 [this will soon be Python 3, on Debian, the corresponding package will be pyflakes3].

Then run pyflakes your_file.sage.py from a standard terminal. You will get a lot of lines of the kind:

your_file.sage.py:XX: undefined name 'Blah'


For each such Blah, in a Sage session, run:

sage: import_statements('Blah')


Sage will give you the line to add at the beginning of your_file.sage.py.

For example, if pyflakes returns:

 your_file.sage.py:XXX: undefined name 'Integer'


The command

sage: import_statements('Integer')


gives

from sage.rings.integer import Integer


which you have to add to the beginning of your_file.sage.py.

Here is a short recipe, assuming that your file is named your_file.sage:.

From a standard terminal, type type:

sage -sh. Within this new shell, whose path contains the sage scripts directory, type: sage-preparse -preparse your_file.sage
 A file named your_file.sage.py will appear. Edit it and remove (or comment) the from sage.all_cmdline import * statement. Now, install pyflakes for Python 2 [this will soon be Python 3, on Debian, the corresponding package will be pyflakes3]. Then run pyflakes your_file.sage.py from a standard terminal. You will get a lot of lines of the kind: your_file.sage.py:XX: undefined name 'Blah'
 For each such Blah, in a Sage session, run: sage: import_statements('Blah')
 Sage will give you the line to add at the beginning of your_file.sage.py. For example, if pyflakes returns:   your_file.sage.py:XXX: undefined name 'Integer'
 The command  sage: import_statements('Integer')
 gives from sage.rings.integer import Integer
 which you have to add to the beginning of your_file.sage.py.