#11003: Improve support for lazy_import inside classes
-------------------------------------------------+--------------------------
Reporter: nthiery | Owner: jason
Type: enhancement | Status:
positive_review
Priority: major | Milestone:
sage-wishlist
Component: misc | Keywords:
Work_issues: | Upstream: N/A
Reviewer: Nicolas M. Thiéry, Florent Hivert | Author: Mike Hansen
Merged: | Dependencies:
-------------------------------------------------+--------------------------
Changes (by hivert):
* reviewer: Nicolas M. Thiéry => Nicolas M. Thiéry, Florent Hivert
Old description:
> Currently, one can do:
>
> {{{
> sage: class foo(object):
> ... bar = LazyImport('sage.bar', 'bar')
> sage: foo.bar
> bar
> }}}
>
> and this works (assuming sage.bar.bar exists of course). As a
> syntactic sugar, it would be nice to have lazy_import work as well, if
> possible with the automatic back-insertion of the object into the
> class after the actual import occurred:
>
> {{{
> sage: class foo(object):
> ... lazy_import('sage.bar', 'bar')
> sage: type(foo.bar)
> <type 'sage.misc.lazy_import.LazyImport'>
> sage: foo.bar
> bar
> sage: type(foo.bar)
> <type 'bar_type>
> }}}
New description:
Currently, one can do:
{{{
sage: class foo(object):
... bar = LazyImport('sage.bar', 'bar')
sage: foo.bar
bar
}}}
and this works (assuming sage.bar.bar exists of course). As a
syntactic sugar, it would be nice to have lazy_import work as well, if
possible with the automatic back-insertion of the object into the
class after the actual import occurred:
{{{
sage: class foo(object):
... lazy_import('sage.bar', 'bar')
sage: type(foo.bar)
<type 'sage.misc.lazy_import.LazyImport'>
sage: foo.bar
bar
sage: type(foo.bar)
<type 'bar_type>
}}}
'''Apply:''' [attachment:trac_11003-folded.patch]
--
--
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/11003#comment:12>
Sage <http://www.sagemath.org>
Sage: Creating a Viable Open Source Alternative to Magma, Maple, Mathematica,
and MATLAB
--
You received this message because you are subscribed to the Google Groups
"sage-trac" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/sage-trac?hl=en.