On Fri, Jun 15, 2018 at 10:25 AM Mikhail V <mikhail...@gmail.com> wrote:
> very uncommon to see standalone statements like: x.method() > Python has many such mutation methods. It sounds like you're judging the frequency of code patterns across all languages instead of just Python. Even then, I don't think that's true. All OO languages that come to mind have that pattern frequently. As for x+=1 it is implementation detail - historical idea of such operators > was > mutating, so at least visually its not like a returning expression. > Incorrect. The += operator was meant as an alias for ``x = x + 1``. The fact that it mutates a list is somewhat of a surprise. Some other languages make no distinction between mutation and reassignment. Perhaps you're thinking of one of those other languages. > and I am not sure about x.method() form - was it meant to hint to the user > about anything? It seemed to me so when I started to learn Python, but its > not. > Yes, it returns None to emphasize that it's a mutation. This is different from the so-called "fluent" design pattern where all mutation methods also return the original object, causing confusion about whether the return value is a copy or not.
_______________________________________________ Python-ideas mailing list Python-ideas@python.org https://mail.python.org/mailman/listinfo/python-ideas Code of Conduct: http://python.org/psf/codeofconduct/