Meaning of in ""? Membership testing empty string literal
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.
That expression is true if wallet_name
is the empty string.
It would probably be clearer if the code had been written as follows:
if wallet_name == '':
Or just:
if not wallet_name: