1
00:00:00,690 --> 00:00:04,640
Hi and welcome to a new section in this course in this section.

2
00:00:04,680 --> 00:00:11,790
I want to talk about Michael Python module's Michael Python module's just like a regular python.

3
00:00:11,790 --> 00:00:18,820
Modules are files that contain functions and code that you can import and use in your own scripts.

4
00:00:19,440 --> 00:00:26,170
Very often we tend to use the word libraries instead of modules, but those two words are equivalent.

5
00:00:26,210 --> 00:00:29,970
You they can use either one and understand what you're talking about myself.

6
00:00:29,980 --> 00:00:33,200
I often use the word libraries instead of modules.

7
00:00:33,750 --> 00:00:39,420
So just wanted to give you a quick example of what a module can do for your programming and for your

8
00:00:39,420 --> 00:00:40,110
productivity.

9
00:00:40,290 --> 00:00:47,640
And in the next few lectures in this section, I'm going to talk about the modules that you find integrated

10
00:00:47,640 --> 00:00:48,850
into my python.

11
00:00:48,870 --> 00:00:54,490
So let's call those built in modules and then there are the community modules.

12
00:00:54,660 --> 00:00:59,120
So these are modules that are contributed by people that use micro python or python.

13
00:00:59,490 --> 00:01:02,910
And what we're going to show you how to install such community modules.

14
00:01:03,900 --> 00:01:11,250
This script is a script that I'm demonstrating in a later lecture, and it's showing how to use a two

15
00:01:11,250 --> 00:01:15,640
by 16 LCD screen with your E.S.P 32.

16
00:01:15,930 --> 00:01:24,120
Now, if you notice here in line thirty seven, I am importing an external module and the name of this

17
00:01:24,120 --> 00:01:26,670
module is E.S.P eight two six six.

18
00:01:26,670 --> 00:01:32,850
And it going see underscore L'Occitane now using the Keywood as.

19
00:01:34,070 --> 00:01:40,640
To nominate a different name by which I'm going to reference the contents of this module in my script

20
00:01:40,640 --> 00:01:47,900
so you can sit down here, for example, in line 44, where I am creating a object out of this eye to

21
00:01:47,900 --> 00:01:55,630
see LCD class that I'm using the nominated names specified after the keyword.

22
00:01:56,030 --> 00:02:02,150
So you can do things like that in order to shorten perhaps a name of a very long named module.

23
00:02:02,750 --> 00:02:04,400
Now, back to the module itself.

24
00:02:04,730 --> 00:02:11,450
The name that I'm using here to input the module is simply the name of the file for that same module.

25
00:02:11,840 --> 00:02:20,120
So if you look here in my micro python device file listing, you'll see that there is a file with the

26
00:02:20,120 --> 00:02:26,750
exact same name, except that it also has the dot p y extension and have opened it up right here.

27
00:02:26,960 --> 00:02:27,960
And you can have a look at it.

28
00:02:27,980 --> 00:02:30,830
So this is the.

29
00:02:31,840 --> 00:02:36,650
Module that I am importing and you can see the code in it and you can see what it does.

30
00:02:37,480 --> 00:02:42,610
Now, the other interesting thing to notice here is that this module actually has one more dependency.

31
00:02:42,620 --> 00:02:48,010
So you can see in line number four, it depends on another module.

32
00:02:48,340 --> 00:02:54,170
That is also an external module that I had to download from its source called LCD API.

33
00:02:54,190 --> 00:03:00,580
And you can get from this the actual file name of the file that contains this module is LCD and the

34
00:03:00,940 --> 00:03:04,990
API dot p y, which is right here.

35
00:03:06,530 --> 00:03:12,230
But this is a fairly large module, don't click on and then you can have a look inside, you can see

36
00:03:12,230 --> 00:03:19,460
that it's called one class here called the LCD API, and it's got a bunch of functions in it.

37
00:03:20,150 --> 00:03:23,320
And so therefore it's quite large.

38
00:03:23,330 --> 00:03:34,280
And for that reason, I'm using the key word import to import a specific class instead of importing

39
00:03:34,280 --> 00:03:35,090
the whole lot.

40
00:03:35,330 --> 00:03:40,270
Now, imagine that this file of this module contained to multiple classes.

41
00:03:40,910 --> 00:03:43,550
So instead of just the single one that this one contains.

42
00:03:43,580 --> 00:03:45,200
Imagine that he had multiple classes.

43
00:03:45,470 --> 00:03:52,610
By using this type of notation, you can narrow down the class or classes that you want to import as

44
00:03:52,610 --> 00:03:59,540
opposed to importing the entire module, which is something very useful when you're working with devices

45
00:03:59,540 --> 00:04:02,070
that have limited capacity.

46
00:04:02,330 --> 00:04:03,580
So all this is stored in RAM.

47
00:04:03,590 --> 00:04:09,990
Of course, when you import and instantiate a class and you have an object to work with or that is in

48
00:04:10,010 --> 00:04:10,350
RAM.

49
00:04:10,730 --> 00:04:18,500
So by being selective about the components of a module that you want to import, then you can preserve

50
00:04:18,500 --> 00:04:23,960
the resources of your microcontroller unit in the same file here.

51
00:04:24,020 --> 00:04:25,730
Just to continue this for one more step.

52
00:04:26,000 --> 00:04:32,960
You can see that we are also importing modules from machine and from time.

53
00:04:33,120 --> 00:04:40,850
And these these modules are built into micro python, which means that we don't have to install the

54
00:04:40,850 --> 00:04:45,170
files that contain those modules like we did with the DSP.

55
00:04:45,170 --> 00:04:54,920
So we can notice here that there is no file called machine PCI or time dot behind this, because these

56
00:04:54,920 --> 00:04:58,560
two modules are built in two micro parties.

57
00:04:58,580 --> 00:05:02,230
They come with the language and they're part of the interpreter.

58
00:05:02,960 --> 00:05:06,680
So that's just the quick introduction about modules.

59
00:05:06,680 --> 00:05:09,540
We can understand the concept behind them and why they are useful.

60
00:05:10,190 --> 00:05:15,860
So that means we can go ahead into the next couple of lectures where I can talk more about built in

61
00:05:15,860 --> 00:05:20,780
modules, show you a few things about them, including where to find the documentation, because there

62
00:05:20,780 --> 00:05:21,980
are a lot of them.

63
00:05:22,520 --> 00:05:25,310
There's no way that I'd be able to cover them in this course.

64
00:05:25,730 --> 00:05:29,540
But I'll give you the source of all the information that you need.

65
00:05:29,870 --> 00:05:35,750
And then in the lecture after that, I'll show you how to search the community on the Internet in order

66
00:05:35,750 --> 00:05:42,620
to look and find micro python modules that would be useful for your project for go into.
