A Deep-Dive Into Python Classes

Summary

[EuroPython 2011] Mark Smith - 22 June 2011 in "Track Lasagne"

Description

This talk aims to lift the lid on the system that governs how types behave in Python - everything except Metaclasses.

The talk answers questions such as:

  • What is a class, and how can we think of them?
  • How are classes instantiated?
  • How are attributes obtained from a class or an instance?
  • Why do I get a different thing when accessing a method via its class instead of its instance?
  • How do the classmethod and staticmethod decorators work?
  • How can I modify classes and instances after they've been initialised?
  • Does any of this allow me to do any clever tricks?

Attendees should understand at least the basics of object oriented programming in Python. This talk doesn't aim to explain object-orientation, o-o design, or how Python represents objects in C.