attribute save restore

Bruno Desthuilliers bdesth.quelquechose at free.quelquepart.fr
Fri Apr 13 17:02:07 EDT 2007


Carl K a écrit :
> Is there a more elegant way of coding this:
> 
> x=o.p  # save .p
> o.p=0
> o.m()
> o.p=x  # restore .p
> 
> seems very push/pop to me - like there should be a way that doesn't need 
> a var (x) or the save/set lines should be done in one command.
> 
> (personally I think .m would better be implemented by passing in a 
> parameter, but that isn't my choice.)

I was about to comment on this. It looks like o.m is wanting to take an 
optional arg defaulting to o.p, and you should probably propose a patch 
to the author.

My 2 cents




More information about the Python-list mailing list