Hide keyboard shortcuts

Hot-keys on this page

r m x p   toggle line displays

j k   next/prev highlighted chunk

0   (zero) top of page

1   (one) first highlighted chunk

1import sys 

2import warnings 

3 

4 

5class PyStdIsDeprecatedWarning(DeprecationWarning): 

6 pass 

7 

8 

9class Std(object): 

10 """ makes top-level python modules available as an attribute, 

11 importing them on first access. 

12 """ 

13 

14 def __init__(self): 

15 self.__dict__ = sys.modules 

16 

17 def __getattr__(self, name): 

18 warnings.warn("py.std is deprecated, plase import %s directly" % name, 

19 category=PyStdIsDeprecatedWarning) 

20 try: 

21 m = __import__(name) 

22 except ImportError: 

23 raise AttributeError("py.std: could not import %s" % name) 

24 return m 

25 

26std = Std()