2008-08-16 23:26:59 +08:00
|
|
|
|
|
|
|
import sys
|
|
|
|
|
|
|
|
class Std(object):
|
2009-05-08 01:07:22 +08:00
|
|
|
""" makes all standard python modules available as a lazily
|
|
|
|
computed attribute.
|
|
|
|
"""
|
|
|
|
|
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()
|