> > I did this for my favorite proposal, and ended up with the list shown
> > further down below.
> >
> > I think they all looks great!
> >
> The fact that so few were found in whole of the standard library does
> put the use case into question, though, no? Though I am sure more could
> be found with a more thorough scan.

There's lots of code in it that looks like this:

def __init__(self, foo = None):
    if foo is not None:
        self.foo = foo
    else:
        self.foo = self.getFooDefault()

With if/else it can be written:

def __init__(self, foo = None):
    self.foo = foo if foo is not None else self.getFooDefault()

However, I'm convinced that the latter version is less readable than
the former. Often the line becomes more than 80 characters so there's
no gain in translating it to an if-else expression because you would
still have to split the line, other times the condition is so complex
that it deserves its own line. Many opportunities for uses, but
atleast as many for abuses.

--
mvh Björn
_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to