#15648: lazy import attributes of a class are not substituted back after the
import
---------------------------------+------------------------
Reporter: nthiery | Owner:
Type: PLEASE CHANGE | Status: new
Priority: major | Milestone: sage-6.1
Component: misc | Resolution:
Keywords: | Merged in:
Authors: | Reviewers:
Report Upstream: N/A | Work issues:
Branch: | Commit:
Dependencies: | Stopgaps:
---------------------------------+------------------------
Comment (by SimonKing):
See my comment at #10963. We could simply create a lazy class attribute
with an import statement inside. Proof of concept:
{{{
sage: def imported_lazy_class_attribute(module_name, cls_name):
....: return lazy_class_attribute(lambda cls:
getattr(__import__(module_name, {}, {}, [cls_name]),cls_name))
....:
sage: class Test(object):
....: Finite =
imported_lazy_class_attribute('sage.categories.finite_permutation_groups',
'FinitePermutationGroups')
....:
sage: Test.Finite
<class
'sage.categories.finite_permutation_groups.FinitePermutationGroups'>
}}}
Alternatively, since `LazyImport` has some `__get__`: We could make the
lazy import ''behave'' as a class attribute, if it is used as attribute of
a class (`__get__` knows whether it is used as attribute of a class.
--
Ticket URL: <http://trac.sagemath.org/ticket/15648#comment:1>
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 unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sage-trac.
For more options, visit https://groups.google.com/groups/opt_out.