Useless expressions [was Re: Undefined behaviour in C]

Tim Chase python.list at tim.thechases.com
Sun Mar 27 22:59:11 EDT 2016


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.

That said, I'm in the "let the compiler accept valid syntax; leave it
to the linter" camp.

-tkc






More information about the Python-list mailing list