[Prev] Thread [Next]  |  [Prev] Date [Next]

[sage-devel] import_statements Nicolas M. Thiery Sun Feb 19 14:01:13 2012

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.


[1] http://pypi.python.org/pypi/pyflakes
Nicolas M. ThiƩry "Isil" <[EMAIL PROTECTED]>

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