Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-04-10 07:50:27

0001 #!/usr/bin/env python
0002 
0003 import numpy as np
0004 import builtins
0005 
0006 class Base(object):
0007     def __setattr__(self, name:str, value):    
0008         self.__dict__[name] = value
0009         pubpfx = getattr(self, "pubpfx", "DUMMY")   
0010         if name.startswith(pubpfx):
0011             print("publish pubpfx %s attribute to builtins %s:%s" % (pubpfx, name, value))
0012             setattr(builtins, name, value)
0013         pass
0014     pass
0015 
0016 class Demo(Base):
0017     def __init__(self, pubpfx="mt"):
0018         self.pubpfx = pubpfx
0019         hello = "world"
0020         mt_hello = "world"
0021 
0022         self.hello = hello
0023         self.mt_hello = mt_hello
0024     pass
0025 
0026 
0027 if __name__ == '__main__':
0028     d = Demo(pubpfx="mt")
0029 
0030 
0031