News for hackers. Stuff that matters.
Re:PEP 0448 – Additional Unpacking Generalizations by aaronchall on Friday July 17, 2015 @09:31PM (#9906240)
The new answer to this old question: "How can I merge two Python dictionaries in a single expression?" - http://stackoverflow.com/q/38987/541136
Re:PEP 0448 – Additional Unpacking Generalizations by kbd on Friday July 17, 2015 @11:08PM (#9906431)
I wonder why set operations were never supported for dictionaries.

a = b | c

makes perfect sense, vs:

a = b.copy()

a.update(c)

Re:PEP 0448 – Additional Unpacking Generalizations by JoshTriplett on Saturday July 18, 2015 @12:21AM (#9906562)
b|c for sets is commutative; b|c for dictionaries is not. | is not strictly required to commute, but a | operator that does not commute is surprising behavior, and Python doesn't favor surprising behavior.
Re:PEP 0448 – Additional Unpacking Generalizations by kbd on Saturday July 18, 2015 @12:57AM (#9906633)
Thanks! That's exactly what I figured was the reason.

Personally I'd have gone for the practicality beats purity side of things here, but oh well.

Re:PEP 0448 – Additional Unpacking Generalizations by azernik on Saturday July 18, 2015 @04:13AM (#9906956)
I think this is a practicality concern; specifically, with regards to the UI, and following the rule of least surprise to keep user (i.e. programmer) confusion down.
Re:PEP 0448 – Additional Unpacking Generalizations by asgard1024 on Saturday July 18, 2015 @09:41AM (#9907526)
Many years ago, I complained to myself that in Python something required two expressions instead of one. Later I understood - it is probably intentional.

I think there a design guideline for Python that says roughly if you can create an operator/function with a combination of 2 or 3 operators, then it probably is not worth adding. This keeps standard library relatively small and easy to memorize. Many other language keep adding various flavors of operators (and types, too) despite the fact you can easily build one from another.

Re:PEP 0448 – Additional Unpacking Generalizations by klibertp on Saturday July 18, 2015 @11:40AM (#9907789)
Many languages disagree on that rule (2 or 3 operators not worth factoring). Or rather, there are very many different approaches to this problem in various languages. Take a look at Forth, APL, J and possibly Factor to see something radically different than anything you've ever seen (and yes, people do use these).

Personally I find well-chosen names to help readability and may help avoid code duplication. There are 2 or 3 operator long things very much worth naming (see for example https://gist.github.com/piotrklibert/a0849f26523cad3d594e#fi...).

It's a style I call "modern literate," which tries to emulate "literate programming" without extra-language tools. Jeremy Ashkenas uses it in his works, most notably Underscore.js and Backbone.js: the code is simultaneously a manual and a tutorial. See: http://backbonejs.org/docs/backbone.html

Re:PEP 0448 – Additional Unpacking Generalizations by asgard1024 on Saturday July 18, 2015 @06:05PM (#9909131)
I am aware of that, that's why I mention it (and I would add Perl and many Lisp-like languages to your list). I appreciate the path that Python took, though, because it keeps language small and orthogonal. There is lot of value in this approach, especially if you share code with someone outside of the project.

> There are 2 or 3 operator long things very much worth naming

I don't understand your example. But I am talking about functions that are part of the libraries (especially standard ones). How you refactor your code is a different matter.