News for hackers. Stuff that matters.
Re:Python: Uncovering the Overlooked Core Functionalities by crabbone on Tuesday July 25, 2023 @05:33AM (#36859955)
Both your suggestions are awful.

The reason they are bad is that intermediate results are never named (and thus are never explained). In simple situations, it's possible to infer from the context what the author's intention was, but in more complicated cases, if you want to understand someone's code, especially if it's written in the way you did, you'd have to "disassemble" it into simpler operations, name the variables (after investigating or guessing the purpose of each operation) and then try to come up with the full picture of what's going on.

Also, as a style suggestion: avoid using backslashes. In your situation, you could just put dots at the end of the line and it will be enough to not need the backslashes. It adds noise to your code, i.e. characters that add no meaning, just sort of a "scaffolding" to hold your code together.

Re:Python: Uncovering the Overlooked Core Functionalities by gpderetta on Tuesday July 25, 2023 @06:30AM (#36860338)
In my own python toolbox (specifically for the list-of-dictionaries use-case) I inject .log(). calls into the pipeline as need to show what the actual intermediate values would be.

Naming intermediates is fine (and encouraged) if there are actually meaningful names to be given. But sometimes the expression itself is the shortest meaningful name for the expression.

Re backslashes, you can also just wrap the expression in parentheses.

Re:Python: Uncovering the Overlooked Core Functionalities by zelphirkalt on Wednesday July 26, 2023 @07:33AM (#36875970)
A perhaps more appropriate name for your 'log' would be 'peek'. Log reminds of logging, which usually does not return a value, but writes to stdout or a file or similar.
Re:Python: Uncovering the Overlooked Core Functionalities by gpderetta on Wednesday July 26, 2023 @09:20AM (#36877207)
but that's exactly what log does, it is a pipeline filter that logs the content to standard output but otherwise it is passthrough.