Re: [Python-ideas] Left arrow and right arrow operators

2019-03-03 Thread fhsxfhsx
I wonder if it is necessary to add two new operators, and for me, "arrow operator" is not clearer than `+`. Could you explain why do you prefer this operator than `+`? Also -> is a symbol of propositional logic, like ∧ and ∨ , do we also need these operators as well? At 2019-03-03

Re: [Python-ideas] PEP: Dict addition and subtraction

2019-03-03 Thread INADA Naoki
I think "Current Alternatives" section must refer to long existing idiom, in addition to {**d1, **d2}: d3 = d1.copy() d3.update(d2) It is obvious nor easily discoverable, while it takes two lines. "There are no obvious way" and "there is at least one obvious way" is very different. On

Re: [Python-ideas] PEP: Dict addition and subtraction

2019-03-03 Thread James Lu
I propose that the + sign merge two python dictionaries such that if there are conflicting keys, a KeyError is thrown. This way, d1 + d2 isn’t just another obvious way to do {**d1, **d2}. The second syntax makes it clear that a new dictionary is being constructed and that d2 overrides keys

Re: [Python-ideas] Left arrow and right arrow operators

2019-03-03 Thread Oleg Broytman
On Sun, Mar 03, 2019 at 03:46:24PM +0100, francismb wrote: > Hi, > the idea here is just to add the __larrow__ and __rarrow__ operators for > <- and ->. You cannot create operator ``<-`` because it's currently valid syntax: 3 <- 2 is equivalent to 3 < -2 > Regards, > --francis

[Python-ideas] Left arrow and right arrow operators

2019-03-03 Thread francismb
Hi, the idea here is just to add the __larrow__ and __rarrow__ operators for <- and ->. E.g. of use on dicts : >>> d1 = {'a':1, 'b':1 } >>> d2 = {'a':2 } >>> d3 = d1 -> d2 >>> d3 {'a':1, 'b':1 } >>> d1 = {'a':1, 'b':1 } >>> d2 = {'a':2 } >>> d3 = d1 <- d2 >>> d3 {'a':2, 'b':1 } Or on bools as

Re: [Python-ideas] Dict joining using + and +=

2019-03-03 Thread francismb
On 2/27/19 7:14 PM, MRAB wrote: > Are there any advantages of using '+' over '|'? or '<-' (d1 <- d2) meaning merge priority (overriding policy for equal keys) on the right dict, and may be '->' (d1 -> d2) merge priority on the left dict over '+' (d1 + d2) ? E.g.: >>> d1 = {'a':1, 'b':1 } >>> d2

Re: [Python-ideas] Dict joining using + and +=

2019-03-03 Thread francismb
On 3/2/19 11:11 PM, MRAB wrote: > '<=' is for comparison, less-than-or-equal (in the case of sets, subset, > which is sort of the same kind of thing). Using it for anything else in > Python would be too confusing. Understandable, so the the proposed (meaning) overloading for <= is also too