for -- else: what was the motivation?
Peter J. Holzer
hjp-python at hjp.at
Wed Oct 12 19:56:34 EDT 2022
On 2022-10-10 16:48:04 +0000, Robert Latest via Python-list wrote:
> Axy wrote:
> >> Also not really a justification for "shortest block first". Wanting
> >> some elaboration on that. What's the value in it?
> >
> > Well, the value is productivity. No need to save puzzles "what this
> > hanging else belongs to?"
>
> If you find yourself asking that question, the if-block is probably too long to
> begin with.
ACK.
> > Code small things first and return early, same
^^^^^^^^^^^^
> > as taking a test: do easy and quick things first and boring and
> > difficult ones later.
>
> Yes, but in that case you have a very long indented "else" block,
If you return you don't have to indent the rest.
hp
--
_ | Peter J. Holzer | Story must make more sense than reality.
|_|_) | |
| | | hjp at hjp.at | -- Charles Stross, "Creative writing
__/ | http://www.hjp.at/ | challenge!"
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <https://mail.python.org/pipermail/python-list/attachments/20221013/aa1db87d/attachment.sig>
More information about the Python-list
mailing list