mercredi 29 juin 2016

Python: if condition and "with"

I'm just wondering if is there a simpler (shorter) way to write the following (this is a simple example, which in real code is much more complicated)?

def my_fun(value):
 foo = 20
 if value == '0':
    with temporary_set('foo',20):
         #here we run many operations on foo
else:
   #here we run many other operations on foo

Aucun commentaire:

Enregistrer un commentaire