[Python-ideas] "Immutable Builder" Pattern and Operator

Serhiy Storchaka storchaka at gmail.com
Sun Jan 22 17:54:58 EST 2017


On 23.01.17 00:45, Soni L. wrote:
> I've been thinking of an Immutable Builder pattern and an operator to go
> with it. Since the builder would be immutable, this wouldn't work:
>
> long_name = mkbuilder()
> long_name.seta(a)
> long_name.setb(b)
> y = long_name.build()

I think the more pythonic way is:

y = build(a=a, b=b)

A Builder pattern is less used in Python due to the support of keyword 
arguments.




More information about the Python-ideas mailing list