[Python-ideas] "Immutable Builder" Pattern and Operator
Soni L.
fakedme+py at gmail.com
Sun Jan 22 17:45:01 EST 2017
More information about the Python-ideas mailing list
Sun Jan 22 17:45:01 EST 2017
- Previous message (by thread): [Python-ideas] PEP 538 (C locale coercion) now depends on PEP 540 (UTF-8 mode)
- Next message (by thread): [Python-ideas] "Immutable Builder" Pattern and Operator
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
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() Instead, you'd need something more like this: long_name = mkbuilder() long_name = long_name.seta(a) long_name = long_name.setb(b) y = long_name.build() Or we could add an operator to simplify it: long_name = mkbuilder() long_name .= seta(a) long_name .= setb(b) y = long_name.build() (Yes, I'm aware you can x = mkbuilder().seta(a).setb(b), then y = x.build(). But that doesn't work if you wanna "fork" the builder. Some builders, like a builder for network connections of some sort, would work best if they were immutable/forkable.)
- Previous message (by thread): [Python-ideas] PEP 538 (C locale coercion) now depends on PEP 540 (UTF-8 mode)
- Next message (by thread): [Python-ideas] "Immutable Builder" Pattern and Operator
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-ideas mailing list