[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.python

Re: use 'with' to redirect stdout

Neal Becker

2/11/2008 11:41:00 PM

Thanks! I understand this better now. This is really an example of a more
general pattern:

@contextmanager
def rebind_attr(object_, attr, value):
orig = getattr(object_, attr)
setattr(object_, attr, value)
yield
setattr(object_, attr_, orig)