DOs & DONTs for Python Programmer

As a part-time Python programmer, I have to admit that I’m probably could not able to write elegant codes or apps with flexible architects. But I want to list some common DOs and DONTs which I’ve learned from minor & major mistakes.

Top DONTs

  • Try to reinvent wheel(s)
  • Forget to write tests
  • Forget to write comments
  • Assume all input & outputs as designed with checking
  • Balance code length & functionalities

Top DOs

  • Learn build-in functions & existent modules, avoid erroneously thinking they are missing
  • Write test code first, no matter it is TDD or BDD
  • Write comments for God sake
  • Write clear code for both purpose and process code
  • Do log code process details with something better than print
  • Name everything concisely & self-descriptive. PEP is a good & prevalent reference if there are no other mandatory rules
  • Read others’ codes more
  • Try FP style, it is great though hard at changing at first.