* Dave Angel -> seafoid:

One other point: you should always derive a class from some other class, or 'object' by default. So you should being the class definition by:

class Seq(object):

Why? It mainly has to do with super(). But in any case if you omit the 'object' it's an "old style" class, and that's not even supported in 3.x, so it's better to just get in the habit before it matters.

I think it's best to mention that the above applies to Python 2.x.

In Python 3.x, writing

   class Seq:

is equivalent to writing

   class Seq( object ):

E.g.,

  >>> class A: pass
  ...
  >>> A.__bases__
  (<class 'object'>,)
  >>>
  >>> class B( object ): pass
  ...
  >>> B.__bases__
  (<class 'object'>,)
  >>> _


Curiously I can't find anything about 'object' in the language spec, but in the 3.1.1 standard library spec ยง2 "Built-in functions" it says "object is a base for all classes."


Cheers,

- Alf
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to