Mastering Python - Second Edition

Unlock the power of Python by learning effective application development strategies

Python is one of the most powerful, flexible, and popular programming languages in the world. It comes with all new features in version 3.5. With Python, you can write code that is efficient, maintainable, and reusable.

In this second edition of the course, we cover the basics of operating in a Python development environment as well as the advanced topics. We present you with real-world solutions to Python 3.5 and advanced-level concepts such as reactive programming and microservices, introduce ctypes and Cython tools.

You don't need to be familiar with the Python language as we start with Python primer and move on to explain what's new in Python 3.5. You'll get ready to install, create packages, and run them on the command line. Throughout the journey, we'll highlight the major aspects of managing your Python development environment, show you how to handle parallel computation, and help you to master asynchronous I/O with new Python 3.5 to improve the performance of your system.

Finally, you'll learn the secrets of metaprogramming and unit testing in Python—arming you with the perfect skillset to be a Python expert. This course will get you up to speed in everything from basic programming practices to high-end tools and techniques, things that will help you set apart as a successful Python programmer.

Who this course is for

If you are a programmer who is familiar with the basics of Python and you want to broaden your knowledge base to develop projects better and faster, this course is for you. Even if you are not familiar with Python, our course starts with the basics and takes you on a journey to become an expert in the technology.

What you will learn from this course

Table of Contents

  1. Python Primer
    • The Course Overview
    • Python Basic Syntax and Block Structure
    • Built-in Data Structures and Comprehensions
    • First-Class Functions and Classes
    • Extensive Standard Library
    • New in Python 3.5

  2. Setting Up
    • Downloading and Installing Python
    • Using the Command-Line and the Interactive Shell
    • Installing Packages with pip
    • Finding Packages in the Python Package Index

  3. Making a Package
    • Creating an Empty Package
    • Adding Modules to the Package
    • Importing One of the Package's Modules from Another
    • Adding Static Data Files to the Package

  4. Basic Best Practices
    • PEP 8 and Writing Readable Code
    • Using Version Control
    • Using venv to Create a Stable and Isolated Work Area
    • Getting the Most Out of docstrings 1: PEP 257 and docutils
    • Getting the Most Out of docstrings 2: doctest

  5. Making a Command-Line Utility
    • Making a Package Executable via python -m
    • Handling Command-Line Arguments with argparse
    • Interacting with the User
    • Executing Other Programs with Subprocess
    • Using Shell Scripts or Batch Files to Run Our Programs

  6. Parallel Processing
    • Using concurrent.futures
    • Using Multiprocessing

  7. Coroutines and Asynchronous I/O
    • Understanding Why This Isn't Like Parallel Processing
    • Using the asyncio Event Loop and Coroutine Scheduler
    • Waiting for Data to Become Available
    • Synchronizing Multiple Tasks
    • Communicating Across the Network

  8. Metaprogramming
    • Using Function Decorators
    • Function Annotations
    • Class Decorators
    • Metaclasses
    • Context Managers
    • Descriptors

  9. Unit Testing
    • Understanding the Principles of Unit Testing
    • Using the unittest Package
    • Using unittest.mock
    • Using unittest's Test Discovery
    • Using Nose for Unified Test Discover and Reporting

  10. Reactive Programming
    • What Does Reactive Programming Mean?
    • Building a Simple Reactive Programming Framework
    • Using the Reactive Extensions for Python (RxPY)

  11. Microservices
    • Microservices and the Advantages of Process Isolation
    • Building a High-Level Microservice with Flask
    • Building a Low-Level Microservice with nameko

  12. Extension Modules and Compiled Code
    • Advantages and Disadvantages of Compiled Code
    • Accessing a Dynamic Library Using ctypes
    • Interfacing with C Code Using Cython

Copyright © 2016 Packt Publishing

All rights reserved. No part of this course may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, without the prior written permission of the publisher, except in the case of brief quotations embedded in critical articles or reviews. Every effort has been made in the preparation of this course to ensure the accuracy of the information presented. However, the information contained in this course is sold without warranty, either express or implied. Neither the author, nor Packt Publishing, and its dealers and distributors will be held liable for any damages caused or alleged to be caused directly or indirectly by this course. Packt Publishing has endeavored to provide trademark information about all of the companies and products mentioned in this course by the appropriate use of capitals. However, Packt Publishing cannot guarantee the accuracy of this information.

Livery Place
35 Livery Street
Birmingham B3 2PB, UK.
ISBN 978-1-78646-374-6