Meaning of in ""? Membership testing empty string literal
python
Solution
It'll return `True` if `wallet_name` is itself empty:
>>> foo = ''
>>> foo in ''
True
It is horrific though. Just use `if not wallet_name:` instead, or use `or` and do away with the `if` statement altogether:
def determine_db_name():
return wallet_name or "wallet.dat"
which works because `or` short-circuits, returning `wallet_name` if it is not the empty string, otherwise `"wallet.dat"` is returned.
Problem
I stumbled upon this apparently horrific piece of code: ``` def determine_db_name(): if wallet_name in "": return "wallet.dat" else: return wallet_name ``` What is supposed `if xx in "":` to mean? Doesn't it always evaluates to `False`?