Skip to Content
Programming Languages: Concepts and Implementation
book

Programming Languages: Concepts and Implementation

by Saverio Perugini
December 2021
Beginner
840 pages
47h 29m
English
Jones & Bartlett Learning
Content preview from Programming Languages: Concepts and Implementation

A.8 Object-Oriented Programming in Python

Recall that we demonstrated (in Section 6.10.2) how to create a first-class counter closure in Python that encapsulates code and state and, therefore, resembles an object. Here we demonstrate how to use the object-oriented facilities in Python to develop a counter object. In both cases, we are binding an object (here, a function or method) to a specific context (or environment). In Python nomenclature, the closure approach is sometimes called nested scopes. However, in both approaches the end result is the same—a callable object (here, a function) that remembers its context.

A set of 29 code lines in Python for demonstrating how to use object-oriented facilities to develop a counter object.
Description

While the ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Concepts and Semantics of Programming Languages 1

Concepts and Semantics of Programming Languages 1

Therese Hardin, Mathieu Jaume, Francois Pessaux, Veronique Viguie Donzeau-Gouge
Programming C# 10

Programming C# 10

Ian Griffiths

Publisher Resources

ISBN: 9781284222739