Pyli/Methods

From Jonathan Gardner's Tech Wiki
Jump to: navigation, search

Lots of methods.

2 kinds:

  • Object-specific methods. These are methods that only work for certain kinds of objects. They are defined as object methods, not as global functions. Ex: length, sub, el, ...
  • Global methods. These are methosd that either don't have parameters and thus no object, or describe some global behavior. For instance, +, -, divmod.

Methods may be overridden.

  • Object-specific methods are overwritten with derived classes.
  • Global methods usually dispatch to some sort of object-specific method, so their behavior can change per-object.