On Fri, Mar 8, 2019 at 1:52 AM Jonathan Fine wrote:
> I've just learnt something new. Look at
>
> >>> from operator import iadd
> >>> lst = [1, 2, 3]
> >>> iadd(lst, 'hi')
> [1, 2, 3, 'h', 'i']
> >>> lst
> [1, 2, 3, 'h', 'i']
>
> This shows that the proposals dict.flow_upd
I've just learnt something new. Look at
>>> from operator import iadd
>>> lst = [1, 2, 3]
>>> iadd(lst, 'hi')
[1, 2, 3, 'h', 'i']
>>> lst
[1, 2, 3, 'h', 'i']
This shows that the proposals dict.flow_update and dict.__iadd__ are
basically the same. (I think this is quite imp
Do go read the recent thread about this - there is a lot there!
Titled something like “fluent programming”
Sorry — on a phone, kinda hard to check now.
-CHB
--
Christopher Barker, PhD
Python Language Consulting
- Teaching
- Scientific Software Development
- Desktop GUI and Web Developme
Why not simply propose an external lib with FluentDict and other
Fluent[Anything] already packaged? I don't know if I'd use it
personnally, but it definitely could have some users.
Le 05/03/2019 à 09:48, Jonathan Fine a écrit :
SUMMARY
Instead of using dict + dict, perhaps use dict.flow_updat
dicttoolz has functions for working with these objects; including
dicttoolz.merge (which returns a reference to the merged dicts but does not
mutate the arguments passed).
https://toolz.readthedocs.io/en/latest/api.html#dicttoolz
https://toolz.readthedocs.io/en/latest/api.html#toolz.dicttoolz.mer
Christopher Barker wrote:
That violates an important convention in Python: mutating methods do not
return self. We really want to preserve that convention.
Smalltalk has an abbreviated way of writing a series of method
calls to the same object:
x doThis; doThatWith: y; doTheOther.
is equiv
I thank Guido and Christopher for their thoughtful comments. You
certainly found some weak points. I chose the name 'flow' to match:
https://en.wikipedia.org/wiki/Fluent_interface#Python
Instead of my previous
arg = defaults.copy().flow_update(options)
one could instead from somewhere import
On Tue, Mar 5, 2019 at 12:53 AM Jonathan Fine wrote:
> SUMMARY
> Instead of using dict + dict, perhaps use dict.flow_update. Here,
> flow_update is just like update, except that it returns self.
That violates an important convention in Python: mutating methods do not
return self. We really want
If you have to tell such a long and convoluted story to explain a name that
you've picked out of the blue and that has no equivalent in other Python
data types, it's probably a bad idea. If you're proposing that other
mutating methods also gain a flow_XXX variant, please, no! That's like the
theory
SUMMARY
Instead of using dict + dict, perhaps use dict.flow_update. Here,
flow_update is just like update, except that it returns self.
BACKGROUND
There's a difference between a sorted copy of a list, and sorting the
list in place.
>>> items = [2, 0, 1, 9]
>>> sorted(items), items
([0
10 matches
Mail list logo