程序员人生 网站导航

Python with

栏目:php教程时间:2015-03-24 08:30:34
def pfname(fun): def wraper(*args,**kwargs): print fun.__name__ return fun(*args,**kwargs) return wraper class ContextWith(): @pfname def __enter__(self): return self @pfname def __exit__(self, exc_type, exc_value, exc_traceback): pass def Helloworld(self): print "Hello world" with ContextWith() as ctx: ctx.Helloworld()



__enter__ Hello world __exit__


------分隔线----------------------------
------分隔线----------------------------

最新技术推荐