>> Hello everyone and welcome back.
This is Lesson 6 of intro to Python on
cybrary on-demand and I am your instructor Joe Perry.
In this video, we're going to cover
the last objective of Lesson 6,
and we're going to learn to use the Python help
and their functions,
and we're also going to take just a second to
have a look at the Python documentation.
To do this, we're going to
work in our interpreter once again.
Again, we're going to type Python
3 at the command line,
and we're going to open a Python 3 interpreter.
The first function we're going to look at is help.
Now, help as I said is a function which means that it
is executed by putting the parentheses after it.
We're not talking about functions very deeply yet,
we'll do that in a later video.
But once you run that command,
it's going to open up
this new subprogram that is
the help program inside of the interpreter.
You can see the instructions there.
Give it the name of a module or a keyword,
or basically any Python topic
and if it has information about it,
it will give you that information.
Now, it can be a little bit tricky to use at time,
just because for example, things like strings,
which are very important components of Python,
you don't actually find by writing the word strings,
but it will try and give you information.
For example, use help serve for help on the str class.
It will try and give you information about how to search
for whatever you're trying to get help on.
Anyway, we're going to look at an example of this,
which is just going to be the print function.
You can see here, if you're familiar with the man pages,
this is going to look pretty familiar to you.
You've got your function at the top,
and then after that you've got
a description of how it's used,
what arguments you would give it.
Then you have an actual text description
prints the values to
a stream or to assist out standard out by default,
sys.stdout is standard out,
that just means print it to your screen.
Which of course we've demonstrated
even if we don't really know what functions are yet,
we've demonstrated what print actually does.
This is just giving us an explanation
in a verbose way with more information about arguments.
That's what help looks like,
you can use help again for pretty much
any module keyword or symbol if it has documentation,
Python we'll be able to provide it.
You leave that just by typing quit,
now that's different from quitting your shell,
which has done with quit with [NOISE] parentheses.
In the help documentation,
you just write the word quit.
We've learned to use help.
Now we're going to learn to use dir
and dir is a tricky one to
explain without a lot of knowledge of Python,
because it deals with a topic called namespaces,
and that's something we're not going to spend
very much time on it all right now,
other than to understand that a
namespace basically just means
the current environment in which you're executing code.
It give you a better way of understanding
that are more clear way,
we're going to run dir right now without
any other arguments or rather any information.
This is a fresh shell,
we haven't really done anything in it yet
that would modify any information.
You can see that we have these list
of items with these underscores around them.
Underscore is basically an indication in
Python that those are internal functions,
they're not really for use
by the programmer or by other programs or other modules,
those are built-in parts of your current namespace.
Now, if you want to see how you can modify a namespace,
a simple example would be creating a
variable which we will call x,
and another variable we will call y.
Now, nothing has happened here because we
were assigning to these variables.
Even though we're in a REPL which
generally reads, executes and prints,
it's not going to print because it's sending
that information to the variable instead.
But we've got x equals one, y equals A.
What we're going to do now, is we're going
to rerun that dir command.
You can see at the end of the list,
these two new items have been included, x and y.
Those are the variables we just created and that's what
the namespace is and that's why I wanted to address it.
What this is,
is it's going to show you everything that is
currently defined that you can have access to.
Additionally, if you run it with command, for example,
running it against one of those variables
, not what I meant to do,
[NOISE] you'll see a bunch more options.
These are all of the things that are
defined within the number variable.
These are all of the functions,
the methods that numbers have access to.
To give an example of that, we can see x.numerator,
which is actually not a method, it's an attribute.
The numerator of course, of one is one,
and we're going to go ahead and clear that screen.
That's help and that's a dir.
Those functions like I said or utility functions,
not only will they become easier to
understand as we go forward and videos,
you're going to find more uses for them.
You can do a bunch of stuff with both of those functions.
I'll give you a ton of information.
Oftentimes when you're trying to run down an error,
those are the places to start because you'll be
able to figure out what's happening with them.
The last thing I want to show you here,
and I think I might still have it up in my Browser,
the Python 3 documentation.
This is the https://docs.python.org or those backslashes,
I can never remember which direction
you call it a slash either way,
docs.python.org, and then it's
the Python 3.7.2 documentation specifically.
You can see here this menu, you've got Python 3.8,
which is still in debt for people
who are using it ahead of time.
3.6, 3.5, and 2.7.
Now we're currently working in 3.6, but like I said,
none of the coding we're going to be doing in this part
of the class or in this class really in general,
is going to run into any differences
between 3.6 and 3.7,
we're not going to worry about that.
Between now and the intermediate in the advanced classes,
we're going to move on to actually
using the proper Python.
Anyway, that's the Python help documentation,
it shouldn't close that window,
I'm not done with it at all.
That's the Python help documentation
you can see that they have tutorials,
library references, language references.
In fact, this tutorial I do want to draw
attention to is absolutely spectacular.
It's all part of the Python installed.
It's all part of Python.
It's free to use and free to read.
I absolutely love it, and in fact,
a lot of our material in this course is
going to be based on information in that tutorial.
In the intermediate and in the advance,
we step away from what the tutorial covers.
But in this intro course, you can absolutely use that,
that's one of the best supplemental
resources you can have access to.
That's the end of this video,
and therefore that's the end of Lesson 6.
In Lesson 6 again,
we discussed the Python syntax,
how to use Python command line,
how to create and execute Python scripts,
and how to use the help and the dir functions.
All of those things, again,
are going to not only make more sense or become
more relevant with each passing video,
I just wanted you to be introduced to them now,
so that we're ready to roll.
Please join us in Lesson 7,
where we're going to be discussing the Python data types.
As always, I am your instructor Joe Perry,
and thank you for watching this video intro to
Python here on Cybrary on-demand.