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

Calvin Spealman cspealma at redhat.com
Thu Sep 27 09:13:14 EDT 2018


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/
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20180927/ccb06bf6/attachment.html>


More information about the Python-ideas mailing list