[issue19953] __iadd__() doc not strictly correct

2019-02-06 Thread Felipe Manzano


Change by Felipe Manzano :


--
pull_requests: +11750, 11751

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue19953] __iadd__() doc not strictly correct

2019-02-06 Thread Felipe Manzano


Change by Felipe Manzano :


--
pull_requests: +11750

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue19953] __iadd__() doc not strictly correct

2019-02-06 Thread Felipe Manzano


Change by Felipe Manzano :


--
pull_requests: +11750, 11751, 11752

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue19953] __iadd__() doc not strictly correct

2014-03-09 Thread priya

Changes by priya priyapappachan...@gmail.com:


Added file: http://bugs.python.org/file34311/my.patch

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue19953
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue19953] __iadd__() doc not strictly correct

2014-03-09 Thread R. David Murray

R. David Murray added the comment:

I wonder if it would be worth adding a sentence that says, In certain 
situations, augmented assignment can result in unexpected errors (see 
http://docs.python.org/3/faq/programming.html#id44).

--
nosy: +r.david.murray

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue19953
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue19953] __iadd__() doc not strictly correct

2014-03-09 Thread priya

Changes by priya priyapappachan...@gmail.com:


Added file: http://bugs.python.org/file34314/my.patch

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue19953
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue19953] __iadd__() doc not strictly correct

2014-03-09 Thread priya

Changes by priya priyapappachan...@gmail.com:


Added file: http://bugs.python.org/file34319/my.patch

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue19953
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue19953] __iadd__() doc not strictly correct

2014-03-09 Thread Roundup Robot

Roundup Robot added the comment:

New changeset f9cb5a44879c by R David Murray in branch '3.3':
#19953: Clarify the wording of the augmented assignment discussion.
http://hg.python.org/cpython/rev/f9cb5a44879c

New changeset 61ceb299a255 by R David Murray in branch 'default':
Merge #19953: Clarify the wording of the augmented assignment discussion.
http://hg.python.org/cpython/rev/61ceb299a255

--
nosy: +python-dev

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue19953
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue19953] __iadd__() doc not strictly correct

2014-03-09 Thread R. David Murray

R. David Murray added the comment:

Thanks, Pryia.

--
nosy:  -python-dev
resolution:  - fixed
stage: needs patch - committed/rejected
status: open - closed
type:  - enhancement

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue19953
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue19953] __iadd__() doc not strictly correct

2013-12-13 Thread Terry J. Reedy

Terry J. Reedy added the comment:

The current doc is correct. Unlike the old incorrect version of the operator 
doc (#7259), it does not say that the call is all of the execution. The 
suggested replacement x = x.__iadd__(y) is called is not correct as 
statements are not called.

The said, it seems that some people miss the fact that augmented assignment 
always does an assignment. So, considering that the first sentence of the 
paragraph, These methods are called to implement the augmented arithmetic 
assignments (+=, -=, *=, /=, //=, %=, **=, =, =, =, ^=, |=). already 
talks about calling, I thing

For instance, to execute the statement x += y, where x is an instance of a 
class that has an __iadd__() method, x.__iadd__(y) is called. If x is an 
instance of a class that does not define a __iadd__() method, x.__add__(y) and 
y.__radd__(x) are considered, as with the evaluation of x + y.

might be replaced by

For instance, if x is an instance of a class with an __iadd__() method, x += y 
is equivalent to x = x.__iadd__(y) . Otherwise, x.__add__(y) and y.__radd__(x) 
are considered, as with the evaluation of x + y.

--
keywords: +patch
nosy: +terry.reedy
stage:  - needs patch
versions:  -Python 2.6, Python 3.1, Python 3.2, Python 3.5

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue19953
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue19953] __iadd__() doc not strictly correct

2013-12-11 Thread ferno

New submission from ferno:

Document in question is:

http://docs.python.org/3.3/reference/datamodel.html#object.__iadd__

The documentation states,

to execute the statement x += y, where x is an instance of a class that has 
an __iadd__() method, x.__iadd__(y) is called.

However, this doesn't appear to be strictly true. According to this, the 
following well-known example:

 a = (1, [2, 3])
 a[1] += [4, 5]
Traceback (most recent call last):
  File stdin, line 1, in module
TypeError: 'tuple' object does not support item assignment
 a
(1, [2, 3, 4, 5])

should give the same behaviour as:

 a = (1, [2, 3])
 a[1].__iadd__([4, 5])
[2, 3, 4, 5]
 a
(1, [2, 3, 4, 5])

However, this snippet DOES give the identical behaviour:

 a = (1, [2, 3])
 a[1] = a[1].__iadd__([4, 5])
Traceback (most recent call last):
  File stdin, line 1, in module
TypeError: 'tuple' object does not support item assignment
 a
(1, [2, 3, 4, 5])

which leads me to suggest that this line of the documentation should be 
adjusted to read:

to execute the statement x += y, where x is an instance of a class that has 
an __iadd__() method, x = x.__iadd__(y) is called.

This fix would incidentally harmonise with the documentation for 
operator.iadd() et al., 
(http://docs.python.org/3.3/library/operator.html#operator.iadd), which had a 
similar problem but was corrected following issue 7259 
(http://bugs.python.org/issue7259), now reading:

a = iadd(a, b) is equivalent to a += b.

--
assignee: docs@python
components: Documentation
messages: 205920
nosy: docs@python, ferno
priority: normal
severity: normal
status: open
title: __iadd__() doc not strictly correct
versions: Python 2.6, Python 2.7, Python 3.1, Python 3.2, Python 3.3, Python 
3.4, Python 3.5

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue19953
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com