Fluent Python: The power of special methods

You’ve used Python for years. Do you really know it? Be brave and skin that Python. In this cut, Luciano Ramalho probes deep into special methods and the Data Model. Become fluent with idiomatic Python.

By Luciano Ramalho
August 1, 2016
Fluent Python - Luciano Ramalho Fluent Python - Luciano Ramalho (source: O'Reilly)

Pythonistas praise a good API by calling it “Pythonic.” That quality has much to do with proper use of the special methods used in the Python Data model, which define the essential behaviors that we expect in objects.

Perhaps you’ve used Python for years. Do you really know it? This tutorial is intended for a Python programmer who has working/practical knowledge of the language plus an understanding of object-oriented programming, who now needs to learn how to write idiomatic APIs. While it’s easy to get started with Python, mastering the language may take a long time. Once you understand special methods and the Python data model, you get a deeper understanding of the language. Luciano Ramalho shows how in this tutorial.

Learn faster. Dig deeper. See farther.

Join the O'Reilly online learning platform. Get a free trial today and find answers on the fly, or master something new and useful.

Learn more

Here’s a clip:

If you learned another object-oriented language before Python, you may have found it strange to call len(collection) instead of collection.len(). This apparent oddity is the tip of an iceberg that, when properly explored, is the key to everything we call Pythonic. The iceberg is called the Python data model, and it describes the API that you can use to make your own objects play well with the most idiomatic language features.

Click here to see the list of tutorials.

Post topics: Software Engineering