[Python-ideas] Add .= as a method return value assignment operator
MRAB
python at mrabarnett.plus.com
Thu Sep 27 13:04:55 EDT 2018
On 2018-09-27 14:13, Calvin Spealman wrote:
> Absolutely -1 on this. Consider the following example:
>
> def encode(s, *args):
> """Force UTF 8 no matter what!"""
> return s.encode('utf8')
>
> text = "Hello, there!"
> text .= encode('latin1')
>
> Do you see how this creates an ambiguous situation? Implicit attribute
> lookup like this is really confusing. It reminds me of the old `with`
> construct in javascript that is basically forbidden now, because it
> created the same situation.
>
I don't believe it's ambiguous. The intention is that:
text .= encode('latin1')
would be equivalent to:
text = text.encode('latin1')
However, I'm also -1 on it.
[snip]
More information about the Python-ideas
mailing list