In this video, Kathryn explains standard libraries and modules in Python. Learn the difference between built-in libraries and modules and why this difference exists. You'll also see why using a standard library might be useful in your personal projects.
- [Narrator] Standard Libraries are available for a variety languages, including Java, Objective-C, C++. So it's important to know what exactly a standard library is. So a standard library is a library that can be used on any machine where you have an application using the specific language. And so here our specific language will be Python and the standard libraries are going to have a bunch of functions that we can use in our code. And so the Python standard library has two things, built-in functions and built-in but imported modules.
And so built-in functions, you've probably already used a lot of these before. But len, min, max, a lot of these you just kind of call and they work. And then we're also going to have built in imported modules. In previous projects you might used math, which is an imported module and you might have done something like math. and then a function name that you wanted to use. And so because you had to do math., math was that imported module and you probably had an import statement at the top of your code.
And so these are the two things that this course is going to focus on. This Python standard library is also going to be available on any machine. And so just because you're using it on a Mac now you would be able to send your code and use it on the PC and it would work there as well. How is this different from an external library? While a standard library is built in an external library is something you have to download separately from the Internet. And usually you're doing this to get some sort of special functionality. And so you can think of this as like your kitchen.
You have things that are built in, kind of, or that you always have. And so this would be like your milk, your eggs, these are things you probably use every day. That's kind of like the methods and functions that are built in to our Python standard library. Our external libraries are things you might have to go to the store to get. So special spices you might need for a certain dish. Then you have to get in your car and go to the store and that's like our external library. And so external libraries are beyond the scope of this course and this course will be focusing on what's inside your kitchen, the Python Standard Library.
- Working with logical and comparison operators
- Getting a list of numbers with the range() and list() functions
- Using mathematical functions such as round(), abs(), and pow()
- Calculating a given input's length
- Importing and using the math module
- Reading a user's command-line arguments
- Getting the current time
- Formatting dates and times with datetime
- Creating a timer
- Using urllib to get content from the Internet
- Using the JSON module to decode content