1
00:00:01,020 --> 00:00:06,990
In this lecture can show you how to install an external module so that you can use it with your micro

2
00:00:06,990 --> 00:00:09,280
python protection, SB 32.

3
00:00:10,230 --> 00:00:11,250
In this case.

4
00:00:11,280 --> 00:00:17,550
In this example, I'm going to use awesome micro python to look for an interesting module.

5
00:00:18,180 --> 00:00:20,020
And there's quite a lot here.

6
00:00:20,020 --> 00:00:24,420
But one that drew my attention is this one here.

7
00:00:24,630 --> 00:00:29,390
Micro math, micro mathematics and analytics looks interesting.

8
00:00:29,400 --> 00:00:34,980
So click on the link here that will take you to the repository for this particular project.

9
00:00:35,730 --> 00:00:43,170
Now, this is a GitHub project and the files are up the top with a description of the project down the

10
00:00:43,170 --> 00:00:43,580
bottom.

11
00:00:44,160 --> 00:00:45,920
So there's a wiki as well.

12
00:00:46,320 --> 00:00:50,520
I can see issues and documentation page.

13
00:00:50,580 --> 00:00:54,090
Let's have a look at those to see what's happening here.

14
00:00:54,660 --> 00:00:56,050
Just click there.

15
00:00:56,460 --> 00:01:01,880
So the wiki doesn't have much just a list of to do items here.

16
00:01:02,850 --> 00:01:05,280
They could have a documentation.

17
00:01:05,280 --> 00:01:10,290
I can take you back to the same GitHub main page.

18
00:01:11,010 --> 00:01:12,870
So not much there either.

19
00:01:13,110 --> 00:01:18,870
But we do have access to the source code so we can drill inside the source code.

20
00:01:18,870 --> 00:01:23,700
The math directory contains a bunch of python files.

21
00:01:24,090 --> 00:01:28,050
You can browse these files to see what this project is all about.

22
00:01:28,050 --> 00:01:35,420
In many cases with micro python projects, the source code itself is the limitation you can find.

23
00:01:35,820 --> 00:01:36,770
So we have a look inside.

24
00:01:36,780 --> 00:01:45,210
Operator, operator, Dopy why has a few simple functions for additional application, power calculations,

25
00:01:45,210 --> 00:01:45,800
etc..

26
00:01:46,410 --> 00:01:50,870
Let's compare it to a look at another one, maybe inside calculus.

27
00:01:51,630 --> 00:01:57,610
So it looks like this is populated with calculus related functions.

28
00:01:58,980 --> 00:02:02,040
OK, it's a few to do items here as well.

29
00:02:03,270 --> 00:02:07,980
But for the sake of this example, this is actually good to go.

30
00:02:08,490 --> 00:02:15,420
So to install it, the first thing to do is to download a zip version of this archive.

31
00:02:15,780 --> 00:02:23,270
So click on the green button, then click on Download Zib that will bring the zip file onto your computer.

32
00:02:23,950 --> 00:02:30,990
And in my case I have already downloaded it and expanded it from the zip file so that this is now the

33
00:02:30,990 --> 00:02:33,480
contents of the repository on my computer.

34
00:02:33,930 --> 00:02:36,720
Now the thing that you need is the math.

35
00:02:36,720 --> 00:02:42,990
That victory, very often a module will contain a single file.

36
00:02:43,320 --> 00:02:49,710
But in some cases, like in this case here, the module comes as a collection of files usually bundled

37
00:02:49,710 --> 00:02:51,320
inside a directory.

38
00:02:51,780 --> 00:02:58,410
So the next thing to do is to get this directory over to a folder that I can use in order to upload

39
00:02:58,410 --> 00:03:01,740
from that folder to my HP through to the server.

40
00:03:01,770 --> 00:03:02,460
Look at 30.

41
00:03:02,730 --> 00:03:05,880
So 30 has got the file step here.

42
00:03:05,880 --> 00:03:13,800
And right now I've browsed into Micro Python E.S.P 32 two, which is sitting on my desktop so I can

43
00:03:13,800 --> 00:03:21,480
either redirect this over to my downloads folder in order to be able to see the math directory inside

44
00:03:21,480 --> 00:03:23,760
this list of files and directories.

45
00:03:24,270 --> 00:03:27,330
Or in this particular case, I'm just going to copy.

46
00:03:28,810 --> 00:03:31,810
This directory and pasted inside.

47
00:03:32,900 --> 00:03:42,990
My open directory, I'm just going to come wait and paste it over, so it's a very standard and move

48
00:03:43,000 --> 00:03:43,810
to the top now.

49
00:03:44,330 --> 00:03:54,290
So there is my UMass directory right there inside my micro python, especially two, and it's cruel.

50
00:03:54,300 --> 00:04:00,500
And yet they just appeared now in my list of files and the phony.

51
00:04:01,370 --> 00:04:02,070
Right there.

52
00:04:02,480 --> 00:04:08,240
And the next thing to do to be able to use it on my experience is to transfer the whole directorate

53
00:04:08,240 --> 00:04:12,540
into my especially to flash memory and system.

54
00:04:12,980 --> 00:04:14,360
So the easiest way to do that is to.

55
00:04:14,360 --> 00:04:14,570
Right.

56
00:04:14,570 --> 00:04:19,550
Click on the director or the TransFair and then select upload forward slash.

57
00:04:20,450 --> 00:04:21,050
Do that.

58
00:04:21,260 --> 00:04:22,610
Wait for a few seconds.

59
00:04:35,060 --> 00:04:38,210
And there's math, right?

60
00:04:40,970 --> 00:04:43,880
So I'm going to do a couple of experiments.

61
00:04:45,450 --> 00:04:54,450
To try out the contents of this module, just trying to expand the shelf part of the window so you can

62
00:04:54,450 --> 00:04:55,980
see more what's happening.

63
00:04:56,220 --> 00:04:59,010
Of course, remember, you always have the source code.

64
00:04:59,010 --> 00:05:05,180
Let's say that you want to play around with the functions inside operator Torpy.

65
00:05:05,580 --> 00:05:09,060
So just double click on Operator to provide to see what's inside.

66
00:05:09,810 --> 00:05:12,590
And you see the three or four functions that are available here.

67
00:05:12,840 --> 00:05:18,340
And the first thing that you want to do is to import the module into your show so that you can use it.

68
00:05:18,750 --> 00:05:28,080
So the easiest way to do that is to say that you want to use the new math module, but specifically

69
00:05:28,080 --> 00:05:30,660
you want to import operator.

70
00:05:31,590 --> 00:05:39,300
So if you just say import your math, then you'll be importing all of the files that are part of the

71
00:05:39,300 --> 00:05:46,290
you must directory, but if you only want to use the functions inside the operator file, then you can

72
00:05:46,290 --> 00:05:53,280
say from your mouth the name of the directory import operator, the name of the file without the extension.

73
00:05:54,260 --> 00:06:05,860
So enter and now we can use the ADD function in this way, so two, three has those two numbers across

74
00:06:05,870 --> 00:06:08,640
and the addition is five.

75
00:06:09,260 --> 00:06:13,640
What about Peter W. Power?

76
00:06:15,330 --> 00:06:18,370
Two in the power of three is eight and so on.

77
00:06:18,380 --> 00:06:19,490
You can subtract.

78
00:06:24,160 --> 00:06:32,050
And it works now in the exact same way as what you've just seen me doing on the show, they can use

79
00:06:32,050 --> 00:06:38,680
the exact same method to import a library file or a module file to your ISP.

80
00:06:38,680 --> 00:06:44,800
Three to one more thing that I want to show you before we close with this lecture, and this section

81
00:06:45,130 --> 00:06:51,000
is to show you what you can do if you only really need one of those files, you don't need all of them.

82
00:06:51,010 --> 00:06:57,370
They may not be taking RAM if you have an import them, but they are taking up precious flash memory

83
00:06:57,370 --> 00:06:57,910
space.

84
00:06:58,240 --> 00:07:00,320
So maybe you don't want all of them.

85
00:07:00,340 --> 00:07:06,640
But let's say that you only want the operator functions.

86
00:07:07,180 --> 00:07:13,330
So let's clean up here and remove the directory from my device.

87
00:07:13,810 --> 00:07:21,730
I can then go to operate on just the single file that I want to store on my micro python device and

88
00:07:21,730 --> 00:07:22,420
upload it.

89
00:07:23,720 --> 00:07:31,490
And that appears here on the same level as the rest of my files, it's not inside a directory this time

90
00:07:31,490 --> 00:07:40,400
around, just going to do actually a soft actually up to a reset in order to reboot essentially my ISP

91
00:07:40,400 --> 00:07:41,960
three, two and clear memory.

92
00:07:42,470 --> 00:07:43,070
All right.

93
00:07:43,580 --> 00:07:53,920
So starting from fresh new, I want to import operator, so just say the import operator.

94
00:07:54,500 --> 00:08:01,670
And now I can use the functions that come with operator and the look inside the file again, just like

95
00:08:01,670 --> 00:08:09,470
before you could say operator, add two and three together and that will give us five.

96
00:08:10,100 --> 00:08:15,560
So there's a couple of of ways by which you can do that, but virtually with every single case you'll

97
00:08:15,560 --> 00:08:23,720
be able to use this methodology to import a module to your ability to be able to use on the show or

98
00:08:23,720 --> 00:08:26,080
through Python filed.
