I have the following decorator inside a module:
class CachedProperty(object): """Decorator that lazy-loads the value of a property. The first time the property is accessed, the original property function is executed. The value it returns is set as the new value of that instance's property, replacing the original method. """ def __init__(self, wrapped): self.wrapped = wrapped try: self.__doc__ = wrapped.__doc__ except: pass def __get__(self, instance, instance_type=None): if instance is None: return self value = self.wrapped(instance) setattr(instance, self.wrapped.__name__, value) return value
I want to import this decorator and other stuff from the module like this:
from clang.cindex import *
But I'm unable to import that single decorator this way, it works if I do:
from clang.cindex import CachedProperty
entonces puedo usar
Why can't I import this class through
* while I'm able to import others?
preguntado el 25 de agosto de 12 a las 05:08
See if there is a variable named
__all__ defined near the top of your module. If so it will have a sequence (list or tuple) of string names assigned to it. These are the public names of the module which are imported by the
from ... import * .
__all__ name defined, all names defined in a module (as well as names imported from other modules), which do not begin with an underscore, are considered to be public.
Asegúrese de que el
__all__ sequence includes the string "CachedProperty".