The Python Standard Library is a set of modules, that are not part of the Python language but are distributed with it. In this course, Getting Started with the Python Standard Library, you'll be provided solutions for common tasks in application development. First, you'll look at powerful extensions to the Python language collections types as well as how to read and store data in different text formats. Next, you'll move on to networking to access web services, email, and more. Finally, you'll learn text processing using regular expressions, random data, and utilities to write command line applications. By the end of this course, you'll have a better understanding of the Python Standard Library.
Douglas Starnes is a polyglot ninja and tech community influencer in the Memphis area making stuff that works on more than just the web. He is a co-director of the Memphis Python User Group and a board member of the Memphis .NET User Group.
Course Overview So, you've learned Python, and are writing your first application. There are many tasks that you could encounter. Maybe you need to access a web service, read data from an XML file, or write a command-line utility. Before writing code to do this yourself, you should check with the Python Standard Library. I'm Douglas Starnes, and I've been writing Python for a number of years, both professionally, and in personal projects, as well. I've delivered many presentations on Python, as a speaker at conferences across the southeast United States. I also run a Python user group, and I just created this course, Getting Started with the Python Standard Library. Over the next few hours, you'll see how the Python Standard Library can help you avoid reinventing the wheel, by leveraging its implementations of common needs found in software development. We'll look at powerful extensions through the Python language collection types, as well as how to read and store data in different text formats. Then, we'll move on to networking to access web services, email, and more. Finally, we'll look at text processing, using regular expressions, random data, and utilities to write command-line applications. Since the Python Standard Library is distributed with the language, it's already installed if you've got Python, so there's no reason not to give it a try. You'll find it could speed up development, reduce the time for design, testing, and maintenance, and in general, make your life as a Python developer, more pleasant. Thanks for watching the course, and I look forward to working with you.
Extended Collection Data Types This first module is going to be about extensions to the built-in collection data types offered by the Python Standard Library. You're probably familiar with the collection types that are part of the Python language itself such as the list or tuple, but the Python Standard Library extends these types to include some useful functionality. Most of these are found in the collections module so you'll need to import it or import a specific type that you want to use. First, we'll look at extensions to the dictionary. We'll see the counter class which automatically maintains a tally of the number of occurrences of a value. We'll see the default dict class which provides default values for keys and we'll meet the ordered dict class that remembers the order in which keys were added. After that, we'll move on to an extension of the tuple type, the named tuple. Named tuples help clear up confusion that can result from the generic indices the built-in tuple depends upon by using names for the values instead. Next, we'll look at a very versatile type, the double ended queue which can represent a stack queue and even a circular queue. And we will also discuss one type that is not in the collections module but is still related to collection types by its behavior. Contrary to what you've been told, we'll see that Python or at least the Python Standard Library does have an array type.
Handling Internet Data This third module will continue the discussion about handling data, but this time we'll look specifically at retrieving data from the Internet. This will primarily be focused on web and HTTP, but we'll also look at email and a few other sources as well. Here are the major topics for this module. First, I'll go over the urllib module. There are several submodules of urllib that I'll cover, but conceptually, it's a high level API for accessing HTTP data and working with URLs. However, it does have some limitations. For example, it can only retrieve data. The lower level HTTP module handles both retrieving and serving of HTTP traffic. It is more flexible, but being lower level, not as user friendly. Next, I'll show off a demo application to put urllib and HTTP to use, by showing how to access RESTful style web services. And finally, we'll see email and a few miscellaneous protocols that you might encounter and how to deal with them.
Utility Modules The last module of this course is entitled Utility Modules. These are modules that come in handy when writing applications, but they really don't have a cohesive theme. So they really aren't odds and ends, they just don't fit into the same category in the Python Standard Library. Here's what we'll be looking at. First is the random module. The Python Standard Library has many mechanisms for generating and selecting random data from existing sources. Random numbers can be a tricky subject, but Python makes it simple. Next is string processing. You should have had some exposure to the built in Python string type before watching this course and in the last module we explored regular expression support for string processing. But there's some more features and helpful items in the string module in the Standard Library. Last is argument parsing. One of the things that Python is great for is writing helper scripts run from the command line. The Python Standard Library can help by managing arguments and options passed through the script. We'll see how the argparse module does this in combination with the other modules to create a random password generator.