# HG changeset patch # User Olivier Delalleau # Date 1285345077 14400 # Node ID 705795076efdf67f1e720394f61df89dfc243be3 # Parent 826d78f0135f93b2d4a621d6896e70dac4c6e745 API_coding_style: Added recommendation about how classes should derive from object diff -r 826d78f0135f -r 705795076efd doc/v2_planning/API_coding_style.txt --- a/doc/v2_planning/API_coding_style.txt Fri Sep 24 01:46:12 2010 -0400 +++ b/doc/v2_planning/API_coding_style.txt Fri Sep 24 12:17:57 2010 -0400 @@ -218,6 +218,19 @@ def f(array=[]): # Dangerous if `array` is modified down the road. ... + * All top-level classes should inherit from ``object``. It makes some + 'under-the-hood' differences that can be very useful for Python black + magic adepts. + + .. code-block:: python + + # Good. + class MyClass(object): + pass + # Bad. + class MyClass: + pass + * Always raise an exception with ``raise MyException(args)`` where ``MyException`` inherits from ``Exception``. This is required for compatibility across all versions of Python.