mardi 5 novembre 2019

Using alias in an if statement

Is there a way in Python to use a function result both as a test of an if statement and as the value inside the statement? I mean something like:

if f(x) as value:
   # Do something with value

Not

value = f(x)
if value:
   # Do something with value

or

with f(x) as value:
   if value:
       # Do something with value

Aucun commentaire:

Enregistrer un commentaire