Wednesday, July 25, 2012

Code then fail...

Lesson for to day: (some best practice i've leart from my experiences)

  1. Every Python function should return a value if it supposed to return a value. You should explicit return None. (Explicit is better than implicit - PEP 20)
    "So if a function is supposed to return a value, then I make sure all code paths have a return, and that the return has a value, even if it is None.
    If a function "doesn't" return a value, that is, if it is never called by someone using its return value, then it's ok to end without a return, and if I need to return early, I use the bare form, return."
  2.  pdb not work on multithreading
  3. careful with copy. Understand when you need deepcopy
  4. You should know how to use debuger, it will save your life one day.
  5. Debugger and unittest will show it value when you found your bug. When you fail!

No comments: