I've just learnt something new. Look at

    >>> from operator import iadd
    >>> lst = [1, 2, 3]
    >>> iadd(lst, 'hi')
    [1, 2, 3, 'h', 'i']
    >>> lst
    [1, 2, 3, 'h', 'i']

This shows that the proposals dict.flow_update and dict.__iadd__ are
basically the same. (I think this is quite important for understanding
the attraction of fluent programming. We ALREADY like and use it, in
the form of augmented assignment of mutables.)

This also shows that
   combined = defaults.copy()
   combined.update(options)
could, if the proposal is accepted, be written as
   defaults.copy().__iadd__(options)

I got the idea from the withdrawn PEP (thank you, Nick Coghlan, for writing it):
PEP 577 -- Augmented Assignment Expressions
https://www.python.org/dev/peps/pep-0577/

-- 
Jonathan
_______________________________________________
Python-ideas mailing list
Python-ideas@python.org
https://mail.python.org/mailman/listinfo/python-ideas
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to