Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Save more on your purchases now! discount-offer-chevron-icon
Savings automatically calculated. No voucher code required.
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Mastering Python Design Patterns

You're reading from   Mastering Python Design Patterns Craft essential Python patterns by following core design principles

Arrow left icon
Product type Paperback
Published in May 2024
Publisher Packt
ISBN-13 9781837639618
Length 296 pages
Edition 3rd Edition
Languages
Arrow right icon
Authors (2):
Arrow left icon
Kamon Ayeva Kamon Ayeva
Author Profile Icon Kamon Ayeva
Kamon Ayeva
Sakis Kasampalis Sakis Kasampalis
Author Profile Icon Sakis Kasampalis
Sakis Kasampalis
Arrow right icon
View More author details
Toc

Table of Contents (17) Chapters Close

Preface 1. Part 1: Start with Principles FREE CHAPTER
2. Chapter 1: Foundational Design Principles 3. Chapter 2: SOLID Principles 4. Part 2: From the Gang of Four
5. Chapter 3: Creational Design Patterns 6. Chapter 4: Structural Design Patterns 7. Chapter 5: Behavioral Design Patterns 8. Part 3: Beyond the Gang of Four
9. Chapter 6: Architectural Design Patterns 10. Chapter 7: Concurrency and Asynchronous Patterns 11. Chapter 8: Performance Patterns 12. Chapter 9: Distributed Systems Patterns 13. Chapter 10: Patterns for Testing 14. Chapter 11: Python Anti-Patterns 15. Index 16. Other Books You May Enjoy

Maintainability anti-patterns

These anti-patterns make your code difficult to understand or maintain over time. We are going to discuss several anti-patterns that should be avoided for better quality in your Python application or library’s code base. We will focus on the following points:

  • Using a wildcard import
  • Look Before You Leap (LBYL) versus Easier to Ask for Forgiveness than Permission (EAFP)
  • Overusing inheritance and tight coupling
  • Using global variables for sharing data between functions

As mentioned for the previous category of anti-patterns, using tools such as Flake8 as part of your developer workflow can be handy to help find some of those potential issues when they are already present in your code.

Using a wildcard import

This way of importing (from mymodule import *) can clutter the namespace and make it difficult to determine where an imported variable or function came from. Also, the code may end up with bugs because of name collision...

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at €18.99/month. Cancel anytime