python - If expression variables inside if block -


this common idiom:

if foo.get("bar"):     bar = foo.get("bar")     # bar 

instead want like

if foo.get("bar") bar:     # bar 

is there way in python?

no, there not.

bar = foo.get('bar') if bar:    ... del bar 

Comments

Popular posts from this blog

user interface - How to replace the Python logo in a Tkinter-based Python GUI app? -

android - Get AccessToken using signpost OAuth without opening a browser (Two legged Oauth) -

org.mockito.exceptions.misusing.InvalidUseOfMatchersException: mockito -