4 ms·
I agree with you. It's very exciting to remove these sorts of redundant lines, but I cannot train my brain to intuitively view that line as it will be interpre
by gonational 8y ago
I agree with you.
It's very exciting to remove these sorts of redundant lines, but I cannot train my brain to intuitively view that line as it will be interpreted.
There is one case where the benefit, IMHO, far outweighs the negatives, and that can be seen in slides 30-31 of Dustin Ingram's slideshow[1].
PEP 572... the day Python jumped the walrus.
1. https://speakerdeck.com/di_codes/pep-572-the-walrus-operator?slide=30 https://speakerdeck.com/di_codes/pep-572-the-walrus-operator...
- ssutch3 8y agoYes, you can. How do you think your brain learned the original way?
- gonational 8y agoIntuition is defined as being based on what one feels to be true even without conscious reasoning. Something that is unnatural, such as an operator mixed with an expression is anything but natural, in the context of Python. I can force myself to recognize the pattern; yes. Also, the example I linked to in the slide show does feel somewhat intuitive (usage in a while loop).
- a1369209993 8y ago> 1. https://speakerdeck.com/di_codes/pep-572-the-walrus-operator?slide=30 https://speakerdeck.com/di_codes/pep-572-the-walrus-operator... Direct link: https://speakerd.s3.amazonaws.com/presentations/025e2c4bf55143678645a1f3a712e7d2/preview_slide_30.jpg https://speakerd.s3.amazonaws.com/presentations/025e2c4bf551... (s/preview_// for a larger version)
- legostormtroopr 8y agoI can't take a programming talk seriously if it declares in giant font "Less lines are better" (slide 38). Any C program can be written as a single line, with no linebreaks - that doesn't make it "better" by any metric. Python is built around its readability, and slide 44: > group = match.group(1) if (match := re.match(data)) else None is anything but. 'match' is assigned after its first use, and it took me far to long to mentally parse what it was doing.
- maceurt 8y agoC is different than python though. Python already forces readability things like forcing indent and newline. In most scenarios making a python program in as few lines as possble will make the program more readible.
- michaelcampbell 8y ago> but I cannot train my brain to intuitively view that line as it will be interpreted. I... don't believe you. "Will not", "refuse to"? Sure. But "cannot", no.