jeudi 14 mai 2015

python: declare variable within if statement

Is there a python built-in to condense:

x = db.get(ID)
if x:
    return foo(x)

Into this:

if db.get(ID) as x:
    return foo(x)

Lines would be saved. Empty pointers would be distant *memory*. I would once again revel in the awesomesauce of python.

Aucun commentaire:

Enregistrer un commentaire