Book Image

Expert Python Programming

By : Tarek Ziadé
Book Image

Expert Python Programming

By: Tarek Ziadé

Overview of this book

<p>Python is a dynamic programming language, used in a wide range of domains by programmers who find it simple, yet powerful. From the earliest version 15 years ago to the current one, it has constantly evolved with productivity and code readability in mind.<br /><br />Even if you find writing Python code easy, writing code that is efficient and easy to maintain and reuse is not so straightforward. This book will show you how to do just that:&nbsp; it will show you how Python development should be done. Python expert Tarek Ziadé takes you on a practical tour of Python application development, beginning with setting up the best development environment, and along the way looking at agile methodologies in Python, and applying proven object-oriented principles to your design.</p>
Table of Contents (21 chapters)
Credits
Foreword
About the Author
About the Reviewers
Preface
Index

Summary


The important points covered by this chapter are:

  • Subtyping built-in types is a great feature, but before doing it, make sure that the existing types aren't suitable without subclassing.

  • Since super usage is tricky:

    • Avoid multiple inheritance in your code.

    • Be consistent with its usage and don't mix new-style and old-style.

    • Check the class hierarchy before calling its methods in your subclass.

  • Descriptors let you customize what should be done when you reference an attribute on an object.

  • Properties are great to build a public API.

  • Meta-programming is very powerful, but remember that it obfuscates the readability of the class design.

The next chapter focuses on choosing good names for code elements, and on API design best practices.