Book Image

Expert Python Programming - Third Edition

By : Michał Jaworski, Tarek Ziadé
Book Image

Expert Python Programming - Third Edition

By: Michał Jaworski, Tarek Ziadé

Overview of this book

Python is a dynamic programming language that's used in a wide range of domains thanks to its simple yet powerful nature. Although writing Python code is easy, making it readable, reusable, and easy to maintain is challenging. Complete with best practices, useful tools, and standards implemented by professional Python developers, the third edition of Expert Python Programming will help you overcome this challenge. The book will start by taking you through the new features in Python 3.7. You'll then learn the advanced components of Python syntax, in addition to understanding how to apply concepts of various programming paradigms, including object-oriented programming, functional programming, and event-driven programming. This book will also guide you through learning the naming best practices, writing your own distributable Python packages, and getting up to speed with automated ways to deploy your software on remote servers. You’ll discover how to create useful Python extensions with C, C++, Cython, and CFFI. Furthermore, studying about code management tools, writing clear documentation, and exploring test-driven development will help you write clean code. By the end of the book, you will have become an expert in writing efficient and maintainable Python code.
Table of Contents (25 chapters)
Free Chapter
1
Section 1: Before You Start
4
Section 2: Python Craftsmanship
12
Section 3: Quality over Quantity
16
Section 4: Need for Speed
20
Section 5: Technical Architecture
23
reStructuredText Primer

What this book covers

Chapter 1, Current Status of Python, showcases the current state of the Python language and its community. We will see how Python is constantly changing, why it is changing, and also why these facts are important for anyone who wants to call themselves a Python professional. We will also take a look at the most popular and canonical ways for working on written in Python—popular productivity tools and conventions that are de facto standards now.

Chapter 2, Modern Python Development Environments, describes modern ways of setting up repeatable and consistent development environments for Python programmers. We will concentrate on two popular tools for environment isolation: virtualenv-type environments and Docker containers.

Chapter 3, Modern Syntax Elements – Below the Class Level, focuses on best practices for writing code in Python (language idioms) and also provides a summary of selected elements of Python syntax that may be new for intermediate Python users or those experienced with older versions of Python. We will also take a look at useful notes about internal CPython-type implementations and their computational complexities as a rationale for provided idioms.

Chapter 4, Modern Syntax Elements – Above the Class Level, covers more advanced object-oriented concepts and mechanisms available in Python.

Chapter 5, Elements of Metaprogramming, presents an overview of common approaches to metaprogramming available to Python programmers.

Chapter 6, Choosing Good Names, explains what is the most widely-adopted style guide for Python code (PEP-8) and when and why developers should follow it. We will also take a look at some of the author's general advice for naming things.

Chapter 7, Writing a Package, describes the current state of Python packaging and best practices for creating packages that are to be distributed as open source code in the Python Package Index (PyPI). We will also cover an often overlooked topic of Python – standalone executables.

Chapter 8, Deploying Code, presents some common lightweight tools for deploying Python code on remote servers. Deployment is one of the fields where Python shines are backends for web-based services and applications.

Chapter 9, Python Extensions in Other Languages, explains why writing extensions in C and C++ for Python can sometimes be a good solution and shows that it is not as hard as it seems, as long as the proper tools are used.

Chapter 10, Managing Code, describes how to properly manage a code base and why version control systems should be used. We will also leverage the power of version control systems (especially Git) in implementing continuous processes, such as continuous integration and continuous delivery.

Chapter 11, Documenting Your Project, describes the general rules for writing technical documentation that may be applied to software written in any language, and various tools that are especially useful for creating documentation of your Python code.

Chapter 12, Test-Driven Development, advocates the usage of test-driven development and provides more information on how to use popular Python tools designed for testing.

Chapter 13, Optimization – Principles and Profiling Techniques, discusses the most basic rules of optimization that every developer should be aware of. We will also learn how to identify application performance bottlenecks and use common profiling tools.

Chapter 14, Optimization – Some Powerful Techniques, shows how to use that knowledge to actually make your application run faster or be more efficient in terms of used resources.

Chapter 15, Concurrency, explains how to implement concurrency in Python using different approaches and libraries.

Chapter 16, Event-Driven and Signal Programming, describes what event-driven/signal programming is and how it relates to asynchronous programming and different concurrency models. We will present the various approaches to event-driven programming available to Python programmers, along with useful libraries that enable these patterns.

Chapter 17, Useful Design Patterns, implements a set of useful design patterns and example implementations in Python.

Appendix A, reStructuredText Primer, provides a brief tutorial on how to use reStructuredText markup language.