PEP 308: Pep Update

Andrew Dalke adalke at mindspring.com
Fri Feb 14 12:19:46 EST 2003


James J. Besemer:
> Furthermore, (although I know you'll disagree) I'll point out that your
> general complaint here also constitutes an argument for going with the
> operator based alternative,
>
> a ? b : c
>
> as it couldn't possibly be confused with if/else statements.

   a = (
     #  The value can be cached or in the database
      (is_cached?
       self._get_cache[name]
     :
       self.connection.fetch(name)),  # database already open when getting
source

      # The ownership is stored in the database (if the
      # name starts with "DB") or from the web service
      (x.startswith("DB")?
        self.connection.get_owner(name)
      :
        self.webservice.get_owner_by_name(name))
   )

True, but it doesn't stand out as much.  The use of?: seems
more appropriate for smaller terms, and if/else for larger ones.

> I just wish you'd be willing to be more flexible about other people's
opinion
> about style.

I have at several times agreed that a given expression, when written
with a ternary if/else expression,  is more readable.  My opinion though
is that the overall readability/etc. suffers.  I don't know why I need to
be any more flexible than I have been, nor why I couldn't respond that
you too need to be more flexible.

In any case, I think this will be my last post on this thread, since I am
sure I'm tapped out on it, if not idea-wise then at least emotionally
drained.

                    Andrew
                    dalke at dalkescientific.com






More information about the Python-list mailing list