types Module Workbook Added to Standard Library Learning Path
Source: Dev.to
Overview
I’ve completed and uploaded the types module workbook to my standardlib-datastruct repository. This workbook dives into Python’s runtime object types and CPython internals, providing 18 exercises that cover the most important types from the types module. The goal is comprehensive coverage rather than a specific order, helping you master the types that power Python under the hood.
Types Covered
Function and Method Types
FunctionTypeandLambdaType– regular functions and lambdasMethodType– bound methodsBuiltinFunctionTypeandBuiltinMethodType– built‑in callables
Async and Generator Types
GeneratorType– regular generatorsAsyncGeneratorType– async generatorsCoroutineType– coroutine objects
Code and Execution Types
CodeType– compiled bytecode objectsFrameType– execution framesTracebackType– exception tracebacks
Descriptor Types
MemberDescriptorType– class attribute descriptorsWrapperDescriptorType– low‑level built‑in descriptorsGetSetDescriptorType– C‑implemented properties
Utility Types
MappingProxyType– read‑only dictionary viewsModuleType– module objectsEllipsisType– the...singletonNotImplementedType– theNotImplementedsingleton
Workbook Details
- 18 exercises covering the types listed above.
- Each exercise includes a clear problem statement and a complete solution with working code examples.
- The workbook is not beginner‑friendly by design; it assumes you understand Python’s object model and how types work.
Learning Approach
- Focuses on practical, exercise‑driven learning rather than exhaustive reference material.
- Uses Python 3.11.
- Demonstrates how to understand CPython’s internal descriptor types without diving into C code:
MemberDescriptorType– attributes implemented in CPython (e.g., accessing attributes)GetSetDescriptorType– properties implemented in CPython (similar topropertybut in C)WrapperDescriptorType– methods implemented in CPython
Repository
- Repository:
- Files included in the release:
types_exercises_workbook.md– Markdown formattypes_exercises_workbook.pdf– PDF format (generated with Pandoc + MiKTeX)types_workbook.py– Source generator script
Related Work
- Previous additions: functools workbook, itertools workbook.
- This is a living project; more standard library modules will be added as they are completed.
Feel free to download, work through the exercises, and adapt them to your learning style.