Re: [Python-ideas] Reverse assignment operators (=+, =-, =*, =/, =//, =**, =%)

2016-11-15 Thread Paul Moore
On 15 November 2016 at 02:59, Matthias welp wrote: > Mikhail, what Paul probably means here is that python 'operators' are actually > 'syntactic sugar' for functions (it is not recommended to call > these functions directly, but it is possible): More specifically, the meaning of the syntax a = a

Re: [Python-ideas] Reverse assignment operators (=+, =-, =*, =/, =//, =**, =%)

2016-11-14 Thread Jelle Zijlstra
2016-11-14 19:40 GMT-08:00 MRAB : > On 2016-11-15 02:59, Matthias welp wrote: > [snip] > > e.g. if you use 'a = a + 1', python under the hood interprets it as >> 'a = a.__add__(1)', but if you use 'a += 1' it uses 'a.__iadd__(1)'. >> > > FTR, 'a += 1' is interpreted as 'a = a.__iadd__(1)'. Or to

Re: [Python-ideas] Reverse assignment operators (=+, =-, =*, =/, =//, =**, =%)

2016-11-14 Thread MRAB
On 2016-11-15 02:59, Matthias welp wrote: [snip] e.g. if you use 'a = a + 1', python under the hood interprets it as 'a = a.__add__(1)', but if you use 'a += 1' it uses 'a.__iadd__(1)'. FTR, 'a += 1' is interpreted as 'a = a.__iadd__(1)'. ___ Python

Re: [Python-ideas] Reverse assignment operators (=+, =-, =*, =/, =//, =**, =%)

2016-11-14 Thread Matthias welp
>> For a mutable class, A = A + something is fundamentally different from >> A += something. >> >> Paul > Ok I am calmed down already. > But how do you jump to lists already? I started an example with integers. > I just want to increment an integer and I don't want to see any += in my code, > it s

Re: [Python-ideas] Reverse assignment operators (=+, =-, =*, =/, =//, =**, =%)

2016-11-14 Thread Mikhail V
On 15 November 2016 at 00:34, Paul Moore wrote: > On 14 November 2016 at 22:13, Mikhail V wrote: >>> we don't want A = A + 1 to be the same as A += 1 " >> >> This sounds quite frustrating for me, what else could this be but A += 1? >> Would I want a copy with same name? How that will make sense?

Re: [Python-ideas] Reverse assignment operators (=+, =-, =*, =/, =//, =**, =%)

2016-11-14 Thread Paul Moore
On 14 November 2016 at 22:13, Mikhail V wrote: >> we don't want A = A + 1 to be the same as A += 1 " > > This sounds quite frustrating for me, what else could this be but A += 1? > Would I want a copy with same name? How that will make sense? >>> A = [1,2,3] >>> B = A >>> A = A + [1] >>> A [1, 2,

Re: [Python-ideas] Reverse assignment operators (=+, =-, =*, =/, =//, =**, =%)

2016-11-14 Thread David Mertz
This is just a matter of understanding the actual semantics of Python, which is not the same as other languages such as C. In Python the "assignment operator" is a way of *binding a value*. So writing: a = some_expression Is ALWAYS and ONLY binding the value of `some_expression` to the name `a

Re: [Python-ideas] Reverse assignment operators (=+, =-, =*, =/, =//, =**, =%)

2016-11-14 Thread Mikhail V
On 14 November 2016 at 21:52, Todd wrote: >> I can understand you good. But imagine, if Numpy would allow you to >> simply write: >> A = A + 1 >> Which would bring you directly to same internal procedure as A += 1. >> So it does not currently, why? > > > First, because the language doesn't allow

Re: [Python-ideas] Reverse assignment operators (=+, =-, =*, =/, =//, =**, =%)

2016-11-14 Thread Todd
On Mon, Nov 14, 2016 at 3:42 PM, Mikhail V wrote: > On 14 November 2016 at 19:57, Nick Timkovich > wrote: > > Currently, Numpy takes advantage of __iadd__ and friends by performing > the > > operation in-place; there is no copying or other object created. Numpy is > > very thinly C, for better a

Re: [Python-ideas] Reverse assignment operators (=+, =-, =*, =/, =//, =**, =%)

2016-11-14 Thread Thomas Nyberg
On 11/14/2016 03:42 PM, Mikhail V wrote: On 14 November 2016 at 19:57, Nick Timkovich wrote: I can understand you good. But imagine, if Numpy would allow you to simply write: A = A + 1 Which would bring you directly to same internal procedure as A += 1. So it does not currently, why? I've teste

Re: [Python-ideas] Reverse assignment operators (=+, =-, =*, =/, =//, =**, =%)

2016-11-14 Thread Mikhail V
On 14 November 2016 at 19:57, Nick Timkovich wrote: > Currently, Numpy takes advantage of __iadd__ and friends by performing the > operation in-place; there is no copying or other object created. Numpy is > very thinly C, for better and worse (which is also likely where the += > syntax came from).

Re: [Python-ideas] Reverse assignment operators (=+, =-, =*, =/, =//, =**, =%)

2016-11-14 Thread Todd
On Mon, Nov 14, 2016 at 1:21 PM, Mikhail V wrote: > On 14 November 2016 at 12:16, Steven D'Aprano wrote: > > On Mon, Nov 14, 2016 at 01:19:30AM +0100, Mikhail V wrote: > > > > [...] > >> >> A good syntax example: > >> >> > >> >> a = sum (a, c) > > > > There is a reason why mathematicians and acc

Re: [Python-ideas] Reverse assignment operators (=+, =-, =*, =/, =//, =**, =%)

2016-11-14 Thread Nick Timkovich
Currently, Numpy takes advantage of __iadd__ and friends by performing the operation in-place; there is no copying or other object created. Numpy is very thinly C, for better and worse (which is also likely where the += syntax came from). If you're doing vast amounts of numeric computation, it quic

Re: [Python-ideas] Reverse assignment operators (=+, =-, =*, =/, =//, =**, =%)

2016-11-14 Thread Mikhail V
On 14 November 2016 at 12:16, Steven D'Aprano wrote: > On Mon, Nov 14, 2016 at 01:19:30AM +0100, Mikhail V wrote: > > [...] >> >> A good syntax example: >> >> >> >> a = sum (a, c) > > There is a reason why mathematicians and accountants use symbols as a > compact notation for common functions, ins

Re: [Python-ideas] Reverse assignment operators (=+, =-, =*, =/, =//, =**, =%)

2016-11-14 Thread Steven D'Aprano
On Mon, Nov 14, 2016 at 01:19:30AM +0100, Mikhail V wrote: [...] > >> A good syntax example: > >> > >> a = sum (a, c) There is a reason why mathematicians and accountants use symbols as a compact notation for common functions, instead of purely functional notation. Here is a real-world example

Re: [Python-ideas] Reverse assignment operators (=+, =-, =*, =/, =//, =**, =%)

2016-11-13 Thread Mikhail V
On 14 November 2016 at 00:08, Todd wrote: > > On Sun, Nov 13, 2016 at 4:00 PM, Mikhail V wrote: >> >> On 12 November 2016 at 21:08, João Matos wrote: >> >> > What I would like to propose is the creation of the reverse: >> > a =+ c is the same as a = c + a >> > a =- c is the same as a = c - a >>

Re: [Python-ideas] Reverse assignment operators (=+, =-, =*, =/, =//, =**, =%)

2016-11-13 Thread Todd
On Sun, Nov 13, 2016 at 4:00 PM, Mikhail V wrote: > On 12 November 2016 at 21:08, João Matos wrote: > > > What I would like to propose is the creation of the reverse: > > a =+ c is the same as a = c + a > > a =- c is the same as a = c - a > > a =* c is the same as a = c * a > > a =/ c is the sam

Re: [Python-ideas] Reverse assignment operators (=+, =-, =*, =/, =//, =**, =%)

2016-11-13 Thread Mikhail V
On 12 November 2016 at 21:08, João Matos wrote: > What I would like to propose is the creation of the reverse: > a =+ c is the same as a = c + a > a =- c is the same as a = c - a > a =* c is the same as a = c * a > a =/ c is the same as a = c / a > a =// c is the same as a = c // a > a =% c is th

Re: [Python-ideas] Reverse assignment operators (=+, =-, =*, =/, =//, =**, =%)

2016-11-12 Thread Guido van Rossum
I think a stronger argument to reject this (even for Python 4, and even if we could somehow get over the syntactic ambiguity) is that it's confusing. `+=` and `=+` are just visually too close, and the distinction is not all that intuitive. At least for `a += b` the expansion to `a = a + b` is a sim

Re: [Python-ideas] Reverse assignment operators (=+, =-, =*, =/, =//, =**, =%)

2016-11-12 Thread João Matos
Hello, I understand that, but in my view a =- c and a = -c should not be same. Maybe an ideia for Python 4. Best regards, JM On 12-11-2016 20:19, Bernardo Sulzbach wrote: On 2016-11-12 18:08, João Matos wrote: a =- c is the same as a = c - a This would break compatibility. a =- c is

Re: [Python-ideas] Reverse assignment operators (=+, =-, =*, =/, =//, =**, =%)

2016-11-12 Thread Brendan Barnwell
On 2016-11-12 12:18, João Matos wrote:> Hello, > > What I propose is not > a = +5 (see the space between the = and + sign) > but > a =+ 5 (no space between the = and + sign, and there is a space between > + and 5) > > Exactly the same notation (only reversed) as the current assignment > operators.

Re: [Python-ideas] Reverse assignment operators (=+, =-, =*, =/, =//, =**, =%)

2016-11-12 Thread Bernardo Sulzbach
On 2016-11-12 18:08, João Matos wrote: a =- c is the same as a = c - a This would break compatibility. a =- c is a = -c -- Bernardo Sulzbach http://www.mafagafogigante.org/ mafagafogiga...@gmail.com ___ Python-ideas mailing list Python-id

Re: [Python-ideas] Reverse assignment operators (=+, =-, =*, =/, =//, =**, =%)

2016-11-12 Thread João Matos
Hello, What I propose is not a = +5 (see the space between the = and + sign) but a =+ 5 (no space between the = and + sign, and there is a space between + and 5) Exactly the same notation (only reversed) as the current assignment operators. Best regards, JM On 12-11-2016 20:15, אלעזר wr

Re: [Python-ideas] Reverse assignment operators (=+, =-, =*, =/, =//, =**, =%)

2016-11-12 Thread אלעזר
On Sat, Nov 12, 2016 at 10:08 PM João Matos wrote: > > What I would like to propose is the creation of the reverse: > a =+ c is the same as a = c + a > a =+5 already means a becomes 5 > a =- c is the same as a = c - a > a =-5 already means a becomes -5 Elazar

[Python-ideas] Reverse assignment operators (=+, =-, =*, =/, =//, =**, =%)

2016-11-12 Thread João Matos
Hello, I would like to propose some reversed assignment operators. Python already has some assignment operators: a += c is the same as a = a + c a -= c is the same as a = a - c a *= c is the same as a = a * c a /= c is the same as a = a / c a //= c is the same as a = a // c a %= c is the same as