Adventures in Dunderland: Introduction to the Python Data Model

This is a past event

96 people went

Jon M. Huntsman Hall

3730 Walnut St · Philadelphia, PA

How to find us

From the Walnut Street entrance, go to the end of the long hallway, then to the right. G-55 will be on your right.

Location image of event venue

Details

Presented by Walt Mankowski.

Hosted by PhillyPUG at the Wharton School, Huntsman Hall, room G-55.
Doors at 5:30pm, pizza around 6pm, presentation shortly after.

Description

Python is designed to be easy to learn for beginners, and easy to pick up for experience programmers. But Python’s simplicity means you might not be using all the features the language has to offer. This is particularly true if the features don’t exist in the languages you’re used to.

Last year I left academia and got a job at a startup as a Python programmer. I thought I knew the language pretty well, but a few months in I was surprised to discover a language feature I hadn't known about. Python classes have can special methods that can be used to have the classes pretend to be built-in types. These methods provide an interface to the Python data model, and they’re a key feature in writing idiomatic Python code. They can also make code look like complete magic if you don’t know they exist.

In this talk I’ll try to demystify things. I’ll review Python’s double-underscore (“dunder”) methods, which combine ideas from operator overloading, mix-ins, and inheritance, but which are implemented in a unique way by Python. We’ll discuss how they can be used to have your classes emulate the behavior of Python’s internal types like lists and dictionaries.

Bio

Walt is a recovering ivory tower computer scientist. He’s a long-time Perl programmer and short-time Python programmer who enjoys pointing out things that Perl does better than Python to his friends and coworkers. He enjoys Perl, Python, regular expressions, high-performance computing, and Futurama.