Mercurial > pylearn
diff doc/v2_planning/API_coding_style.txt @ 1254:705795076efd
API_coding_style: Added recommendation about how classes should derive from object
author | Olivier Delalleau <delallea@iro> |
---|---|
date | Fri, 24 Sep 2010 12:17:57 -0400 |
parents | 23f63ecf0a9a |
children | b5673b32e8ec |
line wrap: on
line diff
--- 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.