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
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
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
>> 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
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?
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,
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
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
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
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
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).
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
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
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
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
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
>>
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
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
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
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
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.
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
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
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
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
25 matches
Mail list logo