Skip to: site menu | section menu | main content

IronPython in Action News

News on the IronPython in Action book and sources.

Currently viewing: Front Page

Entries tagged “magic methods”

Online Magic Methods Reference Completed

written by Michael Foord, on 4/26/09 8:26 PM.

Appendix B of IronPython in Action is a reference to all the common Python protocol methods. The protocol methods, known as magic methods, start and end with double underscores and are implemented by objects to support iteration, indexing as a container and all the Python protocols. I've been putting parts of the appendix online as I've had time; and it is now complete.

The new sections that I've just added are:

  • Magic attributes
  • Functions and modules

Context managers, the with statement and the descriptor protocol

written by Michael Foord, on 4/22/09 9:19 PM.

I've added another two sections to the magic methods online reference.

See this entry for sections previously added to the magic methods reference. Newly added sections are:

  • Context managers and the with statement
  • The descriptor protocol

More Sections Added to Magic Method Reference

written by Michael Foord, on 4/18/09 2:34 PM.

I've added more sections from appendix B to the online reference on the Python protocol methods.

The protocol methods are the ones that start and end with double-underscores and the different protocols roughly correspond to interfaces in other languages. The new sections added are:

  • Conversion to string
  • Attribute access
  • Numeric types - binary arithmetic operations
  • Numeric types - unary arithmetic operations
  • Numeric types - type conversion

Python Magic Method Reference

written by Michael Foord, on 4/16/09 1:47 PM.

Appendix B of IronPython in Action is a reference to all the common magic methods in Python. The magic methods are used by the Python protocols, like iteration and accessing objects by indexing; they are roughly the equivalent of interfaces in other languages.

As this appendix is a useful reference for both the Python and IronPython communities I'm putting it online.

Formatting the whole of this appendix for the web is quite a big task, so I'm putting it online in stages. Currently up are references on:

  • Object creation
  • Comparison methods
  • Miscellaneous methods
  • Containers and iteration
  • Generator expressions and conditional expressions

As I get new sections up I'll post entries on this blog. Many thanks to Manning Publications for permission to reproduce it.

Back to top