GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • 3.3.1 Basic customization
  • 3.3.2 Customizing attribute access
  • 3.3.3 Emulating callable objects
  • 3.3.4 Emulating sequence and mapping types
  • 3.3.6 Emulating numeric types

This view

  • Original page
  • New address

GeezerVison is showing docs.python.org — 3.3 Special method names

Previous Page Up One Level Next Page Python Reference Manual Contents Index
Previous: 3.2 The standard type Up: 3. Data model Next: 3.3.1 Basic customization


3.3 Special method names

A class can implement certain operations that are invoked by special syntax (such as arithmetic operations or subscripting and slicing) by defining methods with special names. For instance, if a class defines a method named __getitem__(), and x is an instance of this class, then x[i] is equivalent to x.__getitem__(i). (The reverse is not true -- if x is a list object, x.__getitem__(i) is not equivalent to x[i].) Except where mentioned, attempts to execute an operation raise an exception when no appropriate method is defined.


Subsections
  • 3.3.1 Basic customization
  • 3.3.2 Customizing attribute access
  • 3.3.3 Emulating callable objects
  • 3.3.4 Emulating sequence and mapping types
  • 3.3.5 Additional methods for emulation of sequence types
  • 3.3.6 Emulating numeric types


Previous Page Up One Level Next Page Python Reference Manual Contents Index
Previous: 3.2 The standard type Up: 3. Data model Next: 3.3.1 Basic customization

See About this document... for information on suggesting changes.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.