[Python-ideas] Add .= as a method return value assignment operator

Stelios Tymvios stelios.tymvios at icloud.com
Thu Sep 27 10:41:27 EDT 2018


I believe Calvin is right. .= Assumes that every function returns a value or perhaps implies purity. In my opinion, it goes against the notion that explicit is better than implicit.

Stelios Tymvios

> On 27 Sep 2018, at 4:13 PM, Calvin Spealman <cspealma at redhat.com> 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.
> 
>> On Thu, Sep 27, 2018 at 6:49 AM Ken Hilton <kenlhilton at gmail.com> wrote:
>> Hi Jasper,
>> This seems like a great idea! It looks so much cleaner, too.
>> 
>> Would there be a dunder method handling this? Or since it's explicitly just a syntax for "obj = obj.method()" is that not necessary?
>> My only qualm is that this might get PHP users confused; that's really not an issue, though, since Python is not PHP.
>> 
>> Anyway, I fully support this idea.
>> 
>> Sincerely,
>> Ken Hilton;
>> _______________________________________________
>> Python-ideas mailing list
>> Python-ideas at python.org
>> https://mail.python.org/mailman/listinfo/python-ideas
>> Code of Conduct: http://python.org/psf/codeofconduct/
> _______________________________________________
> Python-ideas mailing list
> Python-ideas at python.org
> https://mail.python.org/mailman/listinfo/python-ideas
> Code of Conduct: http://python.org/psf/codeofconduct/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20180927/f913387b/attachment.html>


More information about the Python-ideas mailing list