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

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

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

google shop client API returns 400 bad request error while adding an item -