Python comes with a lot of built in functionality, so,
you want to make use of that functionality,
you don't re-invent the wheel.
Someone else has already done a great job of implementing it for you.
So you have to understand what exactly is there.
A lot of this great functionality,
is in the built in modules,
that come with Python.
So, we need to look through the docs,
and see what modules are actually there.
So, let's do that.
Here we are back at the official Python documentation.
Let's take a look at the Library Reference.
Now if you look at the Table of Contents here,
you can see things that we've looked at before.
Built in functions, built in types, and so on.
But, at some point here,
starting here at Section six,
you can see that things start to be organized into modules,
you can see the string module,
the r e module, and so on.
So, a lot of the functionality that is built into Python is organized into these modules.
So, let's take a look at some of them.
We already know things like date time, what can we look at?
Let's look at pprint here,
data pretty printer. What does that do?
The pprint module provides a capability to pretty print arbitrary Python data structures.
That sounds useful.
Let's take a look at things that we can do.
Well, there's two primary functions here.
The pformat and pprint.
Pformat, takes an object,
and then some parameters that control how the Pretty printing is done,
and then returns us a string,
that is formatted nicely.
Pprint, does pretty much the same thing,
except it prints it out,
instead of returning as a string.
These functions can be quite valuable as it is relatively complicated,
to print complex objects in a pretty way,
and if somebody has already done it in a way that works for us,
well why should we do it again.
Let's take a look at some more modules.
If we go back to the main page,
I can see here there is a module called math, with mathematical function.
So, as this model is always available provides access to
the mathematical functions defined by the C standard.
What does that mean? Let's first look at the ceil function. What does that do?
Returns the ceiling of x the smallest integer greater than or equal to x.
Well, that sounds interesting.
What else do we have here?
Just flip through, okay,
there's a function called isclose.
Return true, if the values a and b are close to each other, and false otherwise.
Well, that sounds useful.
It's not always very meaningful to
compare two floating point numbers are exactly the same,
rather you want to know if they are really close to each other.
So, this looks like a function that could do that.
Then, there are some arguments that allow me to specify what it means to be really close.
We keep scrolling down here,
we can see there is a variety of other kinds of functions.
So, we have some trigonometric functions that we could use,
like sine and cosine and tangent.
So, the math module provides a lot of
different mathematical functions that I probably don't want to implement myself.
Let's take a look at what else we might have available to us.
From scrolling down here.
Here's something that looks interesting, ZIP File.
ZIP File, the zip file format,
is a common archive and compression standard.
This model provides tools to create,
read, write, append, and list as a file.
Well, that sounds useful.
We've been using zip files in
this specialization to allow you to get access to data files.
Here, we could actually work with them directly in Python.
All that you read about how this module works if you're interested.
Let's go back, and look a little bit further and what we have access to.
Interesting, we have access to a module called html,
we have access to sort of web,
sort of things, urllib, http,
all sorts of things that would allow me to access interesting types of data,
and when you process interesting types of data.
So, this page here,
is definitely worth the work.
You can see that there's a huge variety of different
built in modules that come with Python, so,
make sure you familiarize yourself with them before you go off writing
your own code when you might have been able to find it right here.
The intention of this video is not to teach
you how to use all of the Python built-in modules,
or even to teach you how to use any of the Python built-in modules.
Rather, I just wanted to expose you to the fact that there are
a wide array of modules that are already built into Python,
and I want you to be able to use them.
So, when you have a new task that is relatively complicated and you want to start,
the first thing you should do is see if somebody already wrote code to do it for you.
And a great place to do that,
is to check the docs,
and see if there's a built in module that has the functionality that you already need.
If so, go ahead and be lazy. Use it.
Don't rewrite it. We don't want you to reinvent the wheel,
you want to use code that has been written by others.
And if it's a built-in module in Python,
you can rest assured that it is been implemented well, and efficiently.
So, go ahead and use it.