Sign In Start Free Trial
Account

Add to playlist

Create a Playlist

Modal Close icon
You need to login to use this feature.
  • Book Overview & Buying Modern Python Cookbook
  • Table Of Contents Toc
  • Feedback & Rating feedback
Modern Python Cookbook

Modern Python Cookbook - Third Edition

By : Steven F. Lott
4.9 (17)
close
close
Modern Python Cookbook

Modern Python Cookbook

4.9 (17)
By: Steven F. Lott

Overview of this book

Python is the go-to language for developers, engineers, data scientists, and hobbyists worldwide. Known for its versatility, Python can efficiently power applications, offering remarkable speed, safety, and scalability. This book distills Python into a collection of straightforward recipes, providing insights into specific language features within various contexts, making it an indispensable resource for mastering Python and using it to handle real-world use cases. The third edition of Modern Python Cookbook provides an in-depth look into Python 3.12, offering more than 140 new and updated recipes that cater to both beginners and experienced developers. This edition introduces new chapters on documentation and style, data visualization with Matplotlib and Pyplot, and advanced dependency management techniques using tools like Poetry and Anaconda. With practical examples and detailed explanations, this cookbook helps developers solve real-world problems, optimize their code, and get up to date with the latest Python features.
Table of Contents (20 chapters)
close
close
18
Other Books You May Enjoy
19
Index

10.3 Using the match statement

One important reason for defining a collection of closely-related types is to distinguish the processing that applies to the objects. One technique for providing distinct behavior is by using a polymorphic design: a number of subclasses provide distinct implementations of a common function. When working entirely with our own classes, we can design them to have common methods and attributes, but offer distinct behavior depending on which of the subclasses is involved. This is covered in Chapter 8.

This is not generally possible when working with Python’s internal objects, or when working with collections of data that involve a mixture of classes we’ve defined, and built-in classes that are part of Python. In these cases, it’s simpler to rely on type matching to implement distinct behaviors. One approach was shown in the Using the built-in type matching functions recipe in this chapter.

We can also use...

Visually different images
CONTINUE READING
83
Tech Concepts
36
Programming languages
73
Tech Tools
Icon Unlimited access to the largest independent learning library in tech of over 8,000 expert-authored tech books and videos.
Icon Innovative learning tools, including AI book assistants, code context explainers, and text-to-speech.
Icon 50+ new titles added per month and exclusive early access to books as they are being written.
Modern Python Cookbook
notes
bookmark Notes and Bookmarks search Search in title playlist Add to playlist download Download options font-size Font size

Change the font size

margin-width Margin width

Change margin width

day-mode Day/Sepia/Night Modes

Change background colour

Close icon Search
Country selected

Close icon Your notes and bookmarks

Confirmation

Modal Close icon
claim successful

Buy this book with your credits?

Modal Close icon
Are you sure you want to buy this book with one of your credits?
Close
YES, BUY

Submit Your Feedback

Modal Close icon
Modal Close icon
Modal Close icon