Tuesday, February 18, 2014

Classes

Every other class derives from the object class.

>>> help(object)
Help on class object in module builtins:

class object
  |     The most base type


Special methods in Python begin and end with 2 underscores and are called by particular syntax, e.g.:

x.__init__( . . . ) 
x.__eq__(y) <==> x==y
x.__str__() <==> str(x)
x.__floordiv__(y) <==> x//y

Various functions like print() call __str__

No comments:

Post a Comment