About import_statements which does the following:
sage: import_statements(RationalField, IntegerRing)
from sage.rings.rational_field import RationalField
from sage.rings.integer_ring import IntegerRing
On Sat, Feb 18, 2012 at 12:34:41PM -0800, Anne Schilling wrote (slightly edited)
> The only problem with import_statements is that when it is used on
> some object that is imported by default one gets an error, and one
> has to locate the object by hand:
>
> sage: import_statements(ClonableIntArray)
> NameError: name 'ClonableIntArray' is not defined
Yeah, maybe import_statements should run a search_def in case the
object is not imported by default in the interpreter. This would
require passing the name of the object as:
sage: import_statements("ClonableIntArray")
It also would probably require extending search_def to also lookup
classes and not only functions. Please open a ticket if you find this
feature potentially useful, and I might get to it next time I am
bothered by it :-)
The ultimate feature would be to combine this with pyflakes [1] to
propose at once statements for all missing imports in a given file.
Cheers,
Nicolas
[1] http://pypi.python.org/pypi/pyflakes
--
Nicolas M. ThiƩry "Isil" <[email protected]>
http://Nicolas.Thiery.name/
--
To post to this group, send an email to [email protected]
To unsubscribe from this group, send an email to
[email protected]
For more options, visit this group at http://groups.google.com/group/sage-devel
URL: http://www.sagemath.org