A few thoughts while I'm doing this...
- Write things cleanly the first time and save some grey hairs trying to figure out what you did, why you did it, and whether you could use it on a new project later on.
- Think through logical iteration/algorithmic process before creating endless exceptions with "if <variable> == <value>:" statements...
- Raise descriptive errors if the code is executed in ways other than expected and just... dies.
(Prevents: "...uh... um... huh? <opens code, eyes glaze over>" scenario)
- Comments. What did you want to do with that function?
- Doing something more than once or twice in your function? Write a new function to handle it.
- Add comments to explain dependencies...
- When writing tools, try to compile commonly imported self-written functions/modules to reduce the amount of gopher-tunneling.
- If there is some condition or situation needed when running script, comment on what it was.
("Oh... this doesn't work... why? Oh, because the curves selected need to be dynamic and their output has to be named with '<very specific suffix>' ...okaaaay, even though that script might have been useful, there are too many other things I need to look at to spend time setting up that situation to test the script.")
- For the love of God, comment and date updates to code in the header. Less of an issue if working with a release system or git repository or whatever which keeps track of changes. For little personal code which may be saved in more than one place, keep track of the dates and changes made. Can help prevent needing to solve the same problem/bug again.