Python with

前端之家收集整理的这篇文章主要介绍了Python with前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
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__


猜你在找的PHP相关文章