Advanced Python Exercises
Table of Contents
1. Feature Ecosystem
The diagram below maps Python's advanced features by conceptual layer: from the object model foundations (metaclasses, descriptors) at the bottom, through callable abstractions (decorators, closures), iteration and control flow (generators, context managers), up to the async concurrency layer introduced in Python 3.5.
2. Topics
corrected
Checked each topic's Python-version/year claim against the originating PEP. Decorators (PEP 318) and generator expressions (PEP 289) are both Python 2.4, released November 30, 2004 -- the list gave 2005 for both; corrected to 2004. Remaining version/year claims (Python 1.0 through 3.5, items 2-8 and 10) match official release dates.
- Decorators
- Introduced in Python 2.4 (2004)
- Similar concepts: Annotations (Java), Attributes (C#)
- Generators
- Introduced in Python 2.2 (2001)
- Similar concepts: Iterator (Java), IEnumerable (C#)
- Context Managers
- Introduced in Python 2.5 (2006)
- Similar concepts: try-with-resources (Java), using (C#)
- Metaclasses
- Introduced in Python 2.2 (2001)
- Similar concepts: Reflection (Java), Reflection (C#)
- Descriptors
- Introduced in Python 2.2 (2001)
- Similar concepts: Property (C#), Getter/Setter (Java)
- Abstract Base Classes (ABC)
- Introduced in Python 2.6 (2008)
- Similar concepts: Interface (Java), Abstract Class (C#)
- Coroutines and Asynchronous Programming
- Coroutines introduced in Python 2.5 (2006)
- Async/await syntax introduced in Python 3.5 (2015)
- Similar concepts: Coroutines (C#), CompletableFuture (Java)
- Operator Overloading
- Introduced in Python 1.0 (1994)
- Similar concepts: Operator Overloading (C++), Operator Overloading (C#)
- Advanced List Comprehensions and Generator Expressions
- List comprehensions introduced in Python 2.0 (2000)
- Generator expressions introduced in Python 2.4 (2004)
- Similar concepts: Stream API (Java), LINQ (C#)
- Closures
- Introduced in Python 2.2 (2001)
- Similar concepts: Lambda Expressions (Java), Anonymous Functions (C#)
3. Instructions
For each topic, complete the exercise in the corresponding Python file.
4. Resources
4.2. Books
- Fluent Python by Luciano Ramalho
- Python Workout by Reuven M. Lerner
- Practices of the Python Pro by Dane Hillard
- Effective Python: 90 Specific Ways to Write Better Python by Brett Slatkin
- Python Cookbook by David Beazley and Brian K. Jones
- Python Tricks: A Buffet of Awesome Python Features by Dan Bader
4.4. Blogs and Articles
4.7. YouTube Channels
- Python Documentation: https://docs.python.org/
- Real Python: https://realpython.com/
5. Related
- Python 3 – the language reference these exercises sit on
- Python Standard Library Highlights – the modules the exercises lean on
- Python's functools Module: Higher-Order Functions and Decorators – decorators and closures, in depth
- Itertools Tutorial – generators and lazy iteration, in depth