Mastering Python 3 I/O

Copyright (C) 2011
David M. Beazley
http://www.dabeaz.com

Presented at PyCon'11, March 10, 2011, Atlanta, Georgia.

Note: Click here for the 2010 version of this tutorial.

Introduction

As most Python programmers know, Python 3 breaks backwards compatibility with Python 2 both in syntax and new semantics of built-in operations. One of the most radical changes concerns the ground-up redesign of the I/O system. This tutorial aims to take a tour of the new I/O system and issues that are critical to know about if you're going to port existing code. Topics include text processing, binary data handling, system interfaces, io library module, and porting advice.

Support Files

The following file contains some supporting data files that are used in some of the code samples. There are also some code fragments to experiment with things.

This download also includes all of the code samples that follow below.

Code Samples

Here are a few code samples that you can use to try things things out during the course. The course doesn't rely heavily upon these examples, but I'll try a few out here and there.

Preliminaries:

Part 1 : Introducting Python 3

Part 2 : Working with Text

Part 3 : Printing and Formatting

Part 4 : Binary Data Handling

Part 5 : The io module

These files have a few simple performance tests for comparing different file modes, encodings, etc. You should try these under both Python 2 and 3.

Part 6 : System Interfaces

No files

Part 7 : Library Design Issues

No files.

Feedback

I'm always looking for ways to improve presentation materials and examples. Send your ideas to dave@dabeaz.com.


Copyright (C) 2005-2024, David Beazley