PEP 308: Alternative conditional operator forms
Andrew Dalke
adalke at mindspring.com
Tue Feb 11 17:36:30 EST 2003
Hmmm. Been considering the latest syntax, which as I understand it
allows
a = if x: y() else: z()
This also means
# get the 2-ple of name's value and who owns it
a = (
# The value can be cached or in the database
if is_cached:
self._get_cache[name]
else:
self.connection.fetch(name), # get it from the database
# The ownership is stored in the database (if the
# name starts with "DB") or from the web service
if x.startswith("DB")
self.connection.get_owner(name)
else:
self.webservice.get_owner_by_name(name)
)
is valid, yes? That is, code which in the small looks like normal Python
if/else statement is really an if/else expression?
I don't like that.
Andrew
dalke at dalkescientific.com
More information about the Python-list
mailing list