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

2017-01-22 Thread Wes Turner
On Sunday, January 22, 2017, Soni L. wrote: > > > On 22/01/17 10:03 PM, Wes Turner wrote: > > > > On Sunday, January 22, 2017, Wes Turner > wrote: > >> Have you looked at pyrsistent for >>

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

2017-01-22 Thread Soni L.
On 22/01/17 10:03 PM, Wes Turner wrote: On Sunday, January 22, 2017, Wes Turner > wrote: Have you looked at pyrsistent for immutable/functional/persistent/copy-on-write data structures in Python?

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

2017-01-22 Thread Wes Turner
On Sunday, January 22, 2017, Wes Turner wrote: > Have you looked at pyrsistent for > immutable/functional/persistent/copy-on-write > data structures in Python? > > https://github.com/tobgu/pyrsistent/ > > (freeze() / thaw()) > > ... e.g. List and Dict NamedTuple values are

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

2017-01-22 Thread Wes Turner
Have you looked at pyrsistent for immutable/functional/persistent/copy-on-write data structures in Python? https://github.com/tobgu/pyrsistent/ (freeze() / thaw()) ... e.g. List and Dict NamedTuple values are not immutable (because append() and update() still work) On Sunday, January 22, 2017,

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

2017-01-22 Thread Ethan Furman
On 01/22/2017 03:30 PM, Soni L. wrote: On 22/01/17 08:54 PM, Serhiy Storchaka wrote: 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()

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

2017-01-22 Thread Soni L.
On 22/01/17 08:54 PM, Serhiy Storchaka wrote: 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 =

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

2017-01-22 Thread Joao S. O. Bueno
This is easy to do in Python, and we already have NamedTuples and other things. If you need such a builder anyway, this snippet can work - no need for special syntax: https://gist.github.com/jsbueno/b2b5f5c06caa915c451253bb4f171ee9 On 22 January 2017 at 20:54, Serhiy Storchaka

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

2017-01-22 Thread Serhiy Storchaka
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

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

2017-01-22 Thread Soni L.
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()

Re: [Python-ideas] Context manager to temporarily set signal handlers

2017-01-22 Thread Giampaolo Rodola'
I don't know if this is related (regarding functions registered in C) but one problem I often have is to always execute exit functions. I have come up with this: http://grodola.blogspot.com/2016/02/how-to-always-execute-exit-functions-in-py.html On Fri, Jan 20, 2017 at 1:46 PM, Thomas Kluyver