Tryag File Manager
Home
-
Turbo Force
Current Path :
/
usr
/
lib
/
python2.4
/
site-packages
/
mx
/
DateTime
/
Upload File :
New :
File
Dir
//usr/lib/python2.4/site-packages/mx/DateTime/LazyModule.pyc
mò ôÔ5;c @ s d Z d f d „ ƒ YZ d S( s Helper to enable simple lazy module import. 'Lazy' means the actual import is deferred until an attribute is requested from the module's namespace. This has the advantage of allowing all imports to be done at the top of a script (in a prominent and visible place) without having a great impact on startup time. Copyright (c) 1999-2000, Marc-Andre Lemburg; mailto:mal@lemburg.com See the documentation for further information on copyrights, or contact the author. All Rights Reserved. t LazyModulec B s, t Z d Z e d „ Z d „ Z d „ Z RS( sá Lazy module class. Lazy modules are imported into the given namespaces whenever a non-special attribute (there are some attributes like __doc__ that class instances handle without calling __getattr__) is requested. The module is then registered under the given name in locals usually replacing the import wrapper instance. The import itself is done using globals as global namespace. Example of creating a lazy load module: ISO = LazyModule('ISO',locals(),globals()) Later, requesting an attribute from ISO will load the module automatically into the locals() namespace, overriding the LazyModule instance: t = ISO.Week(1998,1,1) c C st | | _ | d j o | } n | | _ | i d d ƒ } | o | d | | _ | | _ n | | _ | _ d S( så Create a LazyModule instance wrapping module name. The module will later on be registered in locals under the given module name. globals is optional and defaults to locals. t __name__t t .N( t localst selft __locals__t globalst Nonet __globals__t gett mainnamet nameR t __importname__( R R R R R ( ( t: /usr/lib/python2.4/site-packages/mx/DateTime/LazyModule.pyt __init__# s c C sO | i } t | | i | i d ƒ | i | <} | i i | i ƒ t | | ƒ S( s Import the module now. t *N( R R R t __import__R R t modulet __dict__t updatet getattrt what( R R R R ( ( R t __getattr__8 s &c C s d | i S( Ns <lazy module '%s'>( R R ( R ( ( R t __repr__J s ( R t __module__t __doc__R R R R ( ( ( R R s N( R R ( R ( ( R t ? s