PEP 308: Pep Update

Andrew Dalke adalke at
Thu Feb 13 19:40:09 CET 2003

Raymond Hettinger:
> The leading options on the table are:
> *     (if <cond>: <expr1> else: >expr2>)

BTW, I never did see a response to this comment of mine.  With the
above syntax, this means the following is legal

  # 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.connection.fetch(name),  # database already open when getting

     # The ownership is stored in the database (if the
     # name starts with "DB") or from the web service
     if x.startswith("DB")

That is, code which in the small looks like normal Python if/else
statement is really an if/else expression once you look in the
larger scope, which may be indefinitely away.  Also note that
the indentation level does not matter inside of the "a=(...)"

I don't like that.  I would rather use two temporary names.

                    dalke at

More information about the Python-list mailing list