0345 4506120

Advanced Python: Best Practices and Design Patterns

Expand upon your fundamental Python programming skills to build reliable and stable applications. In this training course, you learn to implement Gang of Four (GoF) design patterns in order to solve commonly recurring, real-world software design programs, thereby avoiding pitfalls and greatly improving the effectiveness of your programming efforts.

  Reset

Learning Objectives

You Will Learn How To

  • Employ design patterns and best practices in Python applications
  • Unit test, debug, and instal Python programs and modules
  • Profile program execution and improve performance
  • Apply advanced Python programming features for efficient, reliable, maintainable programs

Pre-Requisites

Requirements:

  • Working knowledge of Python programming to the level of:    
    • Course, Python Programming Introduction, or at least three to six months of Python programming experience

Software:

  • Concepts taught are applicable to all Linux distributions

Course Content

Course Outline

Object-Oriented Programming in Python

  • Extending classes to define subclasses
  • Inheriting from multiple superclasses and mix-in classes
  • Adding properties to a class
  • Defining abstract base classes

Exploring Python Features

Writing "Pythonic" code

  • Customising iteration and indexing with "magic" methods
  • Modifying code dynamically with monkey patching

Handling Exceptions

  • Raising user-defined exceptions
  • Reducing code complexity with context managers and the "with" statement

Verifying Code and Unit Testing

Testing best practices

  • Developing and running Python unit tests
  • Simplifying automated testing with the Nose package

Verifying code behaviour

  • Mocking dependent objects with the Mock package
  • Asserting correct code behaviour with MagicMock

Detecting Errors and Debugging Techniques

Identifying errors

  • Logging messages for auditing and debugging
  • Checking your code for potential bugs with Pylint

Debugging Python code

  • Extracting error information from exceptions
  • Tracing program execution with the PyCharm IDE

Implementing Python Design Patterns

Structural patterns

  • Implementing the Decorator pattern using @decorator
  • Controlling access to an object with the Proxy pattern

Behavioural patterns

  • Utilising the Iterator pattern with Python generators
  • Laying out a skeleton algorithm in the Template  Method pattern
  • Enabling loose coupling between classes with the Observer pattern

Interfacing with REST Web Services and Clients

Python REST web services

  • Building a REST service
  • Generating JSON responses to support Ajax clients

Python REST clients

  • Sending REST requests from a Python client
  • Consuming JSON and XML response data

Measuring and Improving Application Performance

Measuring Application Execution

  • Timing execution of functions with the "timeit" module
  • Profiling program execution using "cProfile"
  • Manipulating an execution profile interactively with "pstats"

Employing Python language features for performance

  • Efficiently applying data structures, including lists, dictionaries and tuples
  • Mapping and filtering data sets using comprehensions
  • Replacing the standard Python interpreter with PyPy

Installing and Distributing Modules

Managing module versions

  • Installing modules from the PyPi repository using "pip"
  • Porting code between Python versions

Packaging Python modules and applications

  • Establishing isolated Python environments with "virtualenv"
  • Building a distribution package with "setuptools"
  • Uploading your Python modules to a local repository

Concurrent Execution

Lightweight threads

  • Creating and managing multiple threads of control with the Thread class
  • Synchronising threads using locks

Heavy-weight processes

  • Launching operating system commands as subprocesses
  • Synchronising processes with queues
  • Parallelising execution using process pools and Executors

Exams & Certification

End of course exam.

Privacy Notice

In order to provide you with the service requested we will need to retain and use your contact information in accordance with our Privacy Notice. If you choose to provide us with this information you explicitly consent to us using the information as necessary to provide the request service to you. If you do not agree please do not proceed to request the service from us.

Marketing Permissions

Would you like to receive our newsletter and other information on products and services which we think will be of interest to you by email. We will always treat your information with care and in accordance with our Privacy Notice. You are free to withdraw this permission at any time.

 

Online Courses

You may prefer an online course if you are looking for a flexible and cost-effective solution. Online courses allow you to study at your own pace, at a time that suits you.

We have the following eLearning options available:

Virtual Classroom

Virtual classrooms provide all the benefits of attending a classroom course without the need to arrange travel and accomodation. Please note that virtual courses are attended in real-time, commencing on a specified date.

Virtual Course Dates

Our Customers Include