Migrating from Python 2.7 to Python 3

0
Join & Subscribe
LinkedIn Learning
Free Trial Available
English
Certificate Available
2-3 hours worth of material
selfpaced

Overview

Make the switch to Python 3. Learn how to migrate your code from Python 2.7 to Python 3 using manual and automated migration strategies and tools.

Are you still using Python 2.7? Official support for this version ended in January 2020; upgrading is more important than ever. If you've been meaning to make the jump to Python 3, but aren't entirely sure how to use the new features—or how to migrate your existing code—then this course is for you. Instructor Steven Lott illuminates the differences between the two Python versions, going over changes to built-in Python functions and the Python standard library. He also walks through a number of ways to convert your Python 2.7 applications to Python 3, including manual rewrite and automated migration using packages like six, pytest, and 2to3. Along the way, Steven shares his own experiences with this transition and offers helpful suggestions for enhancing the overall quality and performance of your code.

Syllabus

Introduction
  • Getting started with migrating Python
1. Python 2 and Python 3
  • The challenges of migrating from Python 2 to 3
  • Historical overview
  • The official how to guide
  • The obvious differences in Python 3
2. Feature Comparisons
  • The language syntax changes
  • Syntax changes that have to wait
  • Changes to the internal types
  • Changes to Python built-in functions
  • Changes to the Python standard library
3. Conversion Strategies: Manual or Automated
  • Navigation among the strategies
  • Readying the toolbox
  • Manual rewrite
  • Automated migration via 2to3
  • Final cleanup
4. Using Six
  • Overview of the features of six
  • Syntax wrapping with six
  • Handling class definitions with six
  • Using six to manage built-in functions
  • Using six with standard library changes
5. Using Pytest for Unit Testing
  • Overview of the goals of unit testing
  • Capturing Python 2 features as tests
  • Mocking and monkey patching
  • Design for testability
  • Bugs: Fix or preserve?
6. Using 2to3 to Automate Conversion
  • Overview of the features of 2to3
  • Syntax and class definitions
  • Built-ins and library migrations
  • Test automation with tox
  • Type checking with mypy
Conclusion
  • Final thoughts
  • Continuing on with Python 3

Taught by

Steven Lott