Re:Python’s tug of war between beginner-friendly and advance...
by michaelhoffman on Thursday February 04, 2021 @10:05PM
(#26032588)
Whitespace helps too! And I think using `sorted(key=)` is more Pythonic than a generator expression ;)
NumPy also has stuff to solve this sort of thing built-in:
[ Parent
| on HN ]
Re:Python’s tug of war between beginner-friendly and advance...
by ianhorn on Friday February 05, 2021 @02:22AM
(#26033950)
For the last bunch of years, wherever my instinct says to add white space, I instead put a comment. If you want something to be a visually separate entity, it’s the perfect place to put a couple words about that entity, and it still gets the visual separation in an editor with any syntax highlighting at all.
Re:Python’s tug of war between beginner-friendly and advance...
by roelschroeven on Friday February 05, 2021 @05:34AM
(#26034880)
> And I think using `sorted(key=)` is more Pythonic than a generator expression ;)
But it doesn't do the same thing. The original code extracted the xs from the coordinate pairs, sorted; your code sorts the coordinate pairs by their x values, but doesn't extract the xs from them.
Re:Python’s tug of war between beginner-friendly and advance...
by michaelhoffman on Friday February 05, 2021 @01:01PM
(#26039236)
Oops! Good point! Unfortunately too late for me to edit.