Handling 3 operands in an expression without raising an exception
Jussi Piitulainen
jpiitula at ling.helsinki.fi
Sun Sep 29 05:35:17 EDT 2013
Νίκος writes:
> And i don't mean like this:
>
> if not city:
> city ="blabla"
> if not host:
> host="blablabla"
>
>
> Can thes be witten without and if perhaps with the use of 'or'
> operator in 1-line within the except clause?
try:
...
except socket.gaierror as e:
# watch out, a composition of bad advice (on demand)
city, host = ( ('city' in locals() or "blabla"),
('host' in locals() or "blablabla") )
More information about the Python-list
mailing list