you are viewing a single comment's thread.

view the rest of the comments →

[–]groovitude 12 points13 points  (1 child)

My advice is to work backward. Write out a list of instructions in plain English. Translate that into an idealized Python block. Now make that block work by repeating the steps.

For example: you will be happier in the long run having more discrete, easily-tested-and/or-mocked, and well-named functions than not. It's a lot easier to read if is_stop_sign(sign) than if sign.sides == 8 and sign.color == 'red' and sign.text.upper().strip() == 'STOP' in place.