00:06Modules let you run functions on your computer and modules is like a collection of functions.
00:12So for example in a terminal you can type commands, let's say we can type the date
00:17command, we can type the echo command and any command in the terminal.
00:24Now, for example you have the system module and it lets you run any command you want in
00:30from Python.
00:31So you can say import OS, that's the system module, OS is short for operating system.
00:36And the OS module has a function called system.
00:41So how do you call that?
00:42You can say whatever module name with the function name, so os.system and then type whatever command
00:51you want.
00:52And you'll see that once you run this program, Python actually executes this system command.
00:58So I run it and you'll see it executes the system command.
01:02And this works for any file, right?
01:05So you can say OS.system, let's create a file using the system.
01:15You see once we run it, it creates some file.
01:17Now you can also delete files of course using the system command.
01:21You can say remove, we'll remove some file.
01:26And you'll see now when we run the program, it's deleted the file.
01:30So you can use system commands directly from your Python scripts.
01:35And of course system is not the only function that you can use in your computer.
01:43All right, so for example, there are many, many modules and many, many functions.
01:49We can use the glob module and if we say glob.glob with any directory, for example, etc.
02:01It shows you the files and directories in the directory.
02:05So we can say files is, let's call it data and then output it.
02:17So if you run it now, you'll see it didn't show anything, let's just output it directly.
02:35So like this at the asterisk at the end and you'll see it shows all of the data in the,
02:43all of the directories in this case in the slash directory.
02:46Now you can also do it for etc or any directory on your system.
02:51So modules can contain many functions.
02:55For example, you can also use the OS module to list files in the directory.
03:00If you use the OS module, there's a function called list here.
03:08So OS dot list here with whatever directory you want.
03:12For example, the slash and you need to, it returns files.
03:21So we say files is OS dot list here and we output it.
03:26Let's just output every file in the slash directory.
03:31So you'll see it outputs all of the files here.
03:34So modules is basically a collection of functions.
03:37There's many modules.
03:38I just showed you two of them.
03:40There's many more, for example, math and you can say print math dots and there's lots of
03:46mathematical functions here.
03:48So functions are just like functions you wrote for, but they are, and modules is a collection
03:54of one or more functions.
03:56Now there's many, many more modules available for Python.
04:01And why would you want to use this?
04:02Because it saves you lots of time when you don't have to write everything yourself.
04:06You can just import the modules and you can do programming much faster when you use modules.
04:12And sometimes functions can get very complex.
04:14So it saves you a lot of time.
04:17Now if you go to the website pypy.org, so that's the Python package index written like
04:22this, pypy.
04:25You can search for many different packages.
04:28You'll see there's like 300,000 modules available for Python with like basically anything you
04:36would want to have, for example, maybe we want our Python project to search Google.
04:41So let's say type Google.
04:44And you'll see there's lots of stuff related to Google here.
04:47For example, search Google.
04:50And this module lets you search Google search results.
04:56Or maybe you're interested in something totally different.
04:58Maybe you're interested in SSH into some computer.
05:02You type SSH and you'll see many modules related to SSH.
05:07Now whenever you want to install any module, you can type pip install with then the module
05:19name.
05:20So you'll see pip install with your module name.
05:22So inside your terminal you can do that, pip install, whatever you want to install.
05:27If you're using any editor like Visual Studio Code or PyTerm, you can install it within the
05:32editor for your project specifically, which is the better way to do it.
05:36Because if you install inside your system, it will be system-wide.
05:43And it might be that in the future, it can conflict with newer versions of the package
05:46or with other packages.
05:48So if you want to use the terminal, it is useful to set up a virtual environment.
05:52A virtual environment lets you install those packages without conflicting.
05:56But then you would have to type lots of terminal commands.
05:59So when you're programming, it's much easier to use an IDE that sets up the virtual environment
06:04for you.
06:04You don't have to think about it.
06:06If you use Visual Studio or PyCharm or some other editor, it takes care of the modules for
06:13you.
06:13So you can just write your codes and use the functions that you want.
06:18So you can do this.
06:18So let's do it.
06:19So let's do it.
06:19So let's do it.
06:19So let's do it.
06:19So let's do it.
Comments