on-internet
← Community

How to refactor if-else statements containing dictionaries and default values in Python [closed]

Stack Overflow ·

Assuming connectionDetails is a Python dictionary, what's the best practice/most Pythonic way of refactoring code like this? if "host" in connectionDetails: host = connectionDetails["host"] else: host = someDefaultValue

Comments

Sign in or sign up to comment and upvote.

No comments yet.