HI !
I guess everything is in the question ... I was just wondering if there is a nice way in Python to shorten this pattern :
something = get_something()
if something:
do_a_thing_with(something)
Meaning that I would like to enter in the if
context only if the variable something
is not None (or False), and then in this context having this variable set automatically ! Is it possible with with
statement ?
PS : I don't want to have to DEFINE more stuff... I am looking for some statement to use on the fly ?!