lambdak: multi-line lambda implementation in native Python

Ian Kelly ian.g.kelly at gmail.com
Fri Jan 16 00:29:21 EST 2015


On Thu, Jan 15, 2015 at 9:00 PM, Chris Angelico <rosuav at gmail.com> wrote:
> My first response was going to be "Well, you can always add another
> layer of indirection to try to solve your problem", but then I went
> and looked up builders on Wikipedia. Now I'm confused. What can you do
> with a builder that you can't do with a constructor?

In Java you have to write a separate constructor for every conceivable
combination of arguments. If there are a lot of optional arguments,
that's an exponentially large number of constructors. The builder
pattern provides a solution to that problem.

In Python you just have one initializer with defaults for the optional
arguments, so it's not an issue.



More information about the Python-list mailing list