comparison doc/v2_planning/API_coding_style.txt @ 1257:d79070c60546

merge
author gdesjardins
date Fri, 24 Sep 2010 12:54:27 -0400
parents 705795076efd
children b5673b32e8ec
comparison
equal deleted inserted replaced
1256:bf41991692ea 1257:d79070c60546
216 ... 216 ...
217 # Bad. 217 # Bad.
218 def f(array=[]): # Dangerous if `array` is modified down the road. 218 def f(array=[]): # Dangerous if `array` is modified down the road.
219 ... 219 ...
220 220
221 * All top-level classes should inherit from ``object``. It makes some
222 'under-the-hood' differences that can be very useful for Python black
223 magic adepts.
224
225 .. code-block:: python
226
227 # Good.
228 class MyClass(object):
229 pass
230 # Bad.
231 class MyClass:
232 pass
233
221 * Always raise an exception with ``raise MyException(args)`` where ``MyException`` 234 * Always raise an exception with ``raise MyException(args)`` where ``MyException``
222 inherits from ``Exception``. This is required for compatibility across 235 inherits from ``Exception``. This is required for compatibility across
223 all versions of Python. 236 all versions of Python.
224 237
225 .. code-block:: python 238 .. code-block:: python