Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[split] Looping a Program
#3
(Oct-06-2018, 05:12 AM)perfringo Wrote:
(Oct-05-2018, 09:26 PM)volcano63 Wrote: Your solution contains redundant loop and else's

I agree with you that there are redundant loop and else's.

However, we should always keep in mind:

"Programs should be written for people to read, and only incidentally for machines to execute." Abelson and Sussman "Structure and Interpretation of Computer Programs"

"Explicit is better than implicit."

I have found useful (and there are some literature supporting this as well) to write out redundant parts of conditional statements. It's for letting readers of code know that writer of code didn't forget them (therefore line 9 should have been else: pass). Reader doesn't have to check whether missing clause is not needed or it's a bug.

Sure, it makes code more 'bloated', but computer doesn't care and if it may help some human to faster comprehend what code does, why not.

I am no software developer, I use Python for achieving results in another field. Therefore my viewpoint and style is probably not acceptable in professional setting. It's disputable even in non-professional setting Shy

Well, pardon my French, but those are poor excuses for showing bad coding practices Naughty . If you cannot give a good example - better to avoid showing your code as one. (BTW, I remember seeing an excellent Python code produced by geneticists in one of previous incarnations of the forum).

Since you don't care to learn best practices, I hope my comments will be useful as a warning to those trying to learn who stumble upon your code.
Test everything in a Python shell (iPython, Azure Notebook, etc.)
  • Someone gave you an advice you liked? Test it - maybe the advice was actually bad.
  • Someone gave you an advice you think is bad? Test it before arguing - maybe it was good.
  • You posted a claim that something you did not test works? Be prepared to eat your hat.
Reply


Messages In This Thread
[split] Looping a Program - by volcano63 - Oct-05-2018, 09:26 PM
RE: [split] Looping a Program - by micseydel - Oct-09-2018, 12:26 AM
RE: Looping a Program - by perfringo - Oct-06-2018, 05:12 AM
RE: Looping a Program - by volcano63 - Oct-06-2018, 08:31 AM
RE: Looping a Program - by perfringo - Oct-07-2018, 09:00 AM
RE: Looping a Program - by volcano63 - Oct-07-2018, 09:26 AM
RE: Looping a Program - by perfringo - Oct-08-2018, 11:31 AM
RE: Looping a Program - by stullis - Oct-08-2018, 02:38 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  [split] Results of this program in an excel file eisamabodian 1 1,612 Feb-11-2022, 03:18 PM
Last Post: snippsat
  Need help looping this program JakobeTheKid 1 2,128 May-19-2019, 05:30 AM
Last Post: SheeppOSU
  Looping a Program DavidRobinsons 4 3,591 Oct-09-2018, 12:14 AM
Last Post: micseydel
  [split] Coin Flip Program Crackity 5 4,895 Sep-25-2017, 03:48 AM
Last Post: Crackity

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020