标签:python
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__
标签:python
原文地址:http://blog.csdn.net/tanghuanan/article/details/44099921