On Mon, Mar 28, 2016 at 1:59 PM, Tim Chase <python.l...@tim.thechases.com> wrote: > On 2016-03-28 12:38, Chris Angelico wrote: >> I would still look askance at code that adds two things and drops >> the result, though. The compiler can't discard it, but if a linter >> complains, I'd support that. A DSL that requires you to do this is, >> imo, poorly designed. > > Is it only the "*add* two things" or are you decrying any generic > operator that gets evaluated and then drops the result? > > Steven recently opened a thread ["Bash-like pipes in Python"] where > this exact sort of thing would be done: > > get_values() | filter("smith") | sort("income") | send_to_printer() > > Several different solutions were posited with varying degrees of > conciseness-vs-pythonicity-vs-pipe'ness.
I was talking about any operator that, for built-in types, does no mutation and has no effect aside from its return value. So yes, the use of the pipe is a perfect counter-example - or rather, proof that my concern is a code smell rather than fundamentally bad. C++ started it with the iostream << and >> overloads; personally, I think that's more cute than useful, but there are times when it can be extremely useful. So I revise my stance: A DSL that requires you to do this *may be* poorly designed, and needs a very solid justification. > That said, I'm in the "let the compiler accept valid syntax; leave it > to the linter" camp. Yeah definitely. ChrisA -- https://mail.python.org/mailman/listinfo/python-list