Chapter 12.3.1. Python Objects, Inheritance, and Composition

Python is a fully object-oriented language. Every new-style class is derived from object, and it even supports multiple inheritance. Python also supports composition. Its flavor of composition is aggregation. This means that objects can hold references (or pointers) to other objects, but they don’t own them. Ownership implies that the lifetime of the owned object is tied to its owner. Because Python is garbage collected and its garbage collection is based on reference counting, there’s no object ownership in Python. If object A creates an object B and passes a reference to another object B, then B will stay alive as long as either A and C (or any other object) keeps reference to ...

Get Rapid Web Applications with TurboGears: Using Python to Create Ajax-Powered Sites now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.