2008-08-16 23:26:59 +08:00
|
|
|
import sys
|
|
|
|
|
|
|
|
class Std(object):
|
2010-07-27 03:15:15 +08:00
|
|
|
""" makes top-level python modules available as an attribute,
|
|
|
|
importing them on first access.
|
|
|
|
"""
|
2009-05-08 01:07:22 +08:00
|
|
|
|
2008-08-16 23:26:59 +08:00
|
|
|
def __init__(self):
|
|
|
|
self.__dict__ = sys.modules
|
|
|
|
|
|
|
|
def __getattr__(self, name):
|
2009-05-08 01:07:22 +08:00
|
|
|
try:
|
|
|
|
m = __import__(name)
|
|
|
|
except ImportError:
|
|
|
|
raise AttributeError("py.std: could not import %s" % name)
|
|
|
|
return m
|
2008-08-16 23:26:59 +08:00
|
|
|
|
|
|
|
std = Std()
|