1 00:00:12,130 --> 00:00:15,520 Hi to all Piter ninja's, welcome to this video. 2 00:00:16,690 --> 00:00:24,550 Now, once we have completed the parts, the main parts of our group, let's talk about a closer topic 3 00:00:24,790 --> 00:00:26,590 and that would be important. 4 00:00:26,860 --> 00:00:27,460 All right. 5 00:00:27,820 --> 00:00:35,650 So up until this point, we have encountered a classes in the aspect of creating a class. 6 00:00:36,970 --> 00:00:45,520 Doesn't matter if it's a parent and the child or even both, and executing that these methods of that 7 00:00:45,520 --> 00:00:49,210 class using an instance in the same module. 8 00:00:50,230 --> 00:00:56,830 But in real life, sometimes it's a bit different, OK, that some of you is going to apply and be accepted 9 00:00:56,830 --> 00:00:59,620 into I.T. companies. 10 00:00:59,890 --> 00:01:05,600 And over there, obviously, teams, development teams are not working on one file. 11 00:01:05,650 --> 00:01:06,070 All right. 12 00:01:06,370 --> 00:01:10,900 They're working on multiple files, maybe several hundred of files. 13 00:01:11,740 --> 00:01:15,640 And these files are interacting all the time. 14 00:01:15,880 --> 00:01:18,670 They're basing data from one file to another. 15 00:01:19,480 --> 00:01:24,530 One file can execute other files and basically everything is possible. 16 00:01:24,970 --> 00:01:28,420 So this is the topic that we're going to study today. 17 00:01:28,690 --> 00:01:38,320 OK, the interaction between the files can be can be implemented by using a special special property 18 00:01:38,320 --> 00:01:41,800 or special functionality that is called an import. 19 00:01:42,010 --> 00:01:42,360 Right. 20 00:01:42,370 --> 00:01:44,500 And this is what I'm going to talk about right now. 21 00:01:44,860 --> 00:01:45,330 All right. 22 00:01:45,430 --> 00:01:46,510 So let's begin. 23 00:01:47,410 --> 00:01:49,360 So let's assume the following thing. 24 00:01:50,350 --> 00:01:53,080 We're starting off working on a new project. 25 00:01:53,080 --> 00:01:59,140 And in that particular project, we have classes. 26 00:02:00,070 --> 00:02:09,760 The class or multiple classes will be held off in Module A by their execution, will be kept in a different 27 00:02:09,760 --> 00:02:11,660 module and let's call it module B. 28 00:02:12,400 --> 00:02:23,860 So basically what we are willing to achieve is, is to execute the class or classes methods by Module 29 00:02:23,860 --> 00:02:29,430 B, but this Module B should recognize all the content that we have created in Module eight. 30 00:02:29,650 --> 00:02:32,350 So there must be some kind of connection between them. 31 00:02:32,530 --> 00:02:32,850 All right. 32 00:02:33,220 --> 00:02:41,860 And these type of rules and these type of relationship between modules appear in every real project. 33 00:02:42,400 --> 00:02:42,820 All right. 34 00:02:43,300 --> 00:02:49,960 There that thing this relationship between modules can be achieved by the import keyword. 35 00:02:50,170 --> 00:02:54,120 And this is what we're going to learn right now. 36 00:02:54,130 --> 00:02:55,420 And let's see how to do it. 37 00:02:56,320 --> 00:03:04,420 OK, this lecture, we're going to focus on the homework assignment that you had in an inheritance. 38 00:03:05,230 --> 00:03:09,730 We have created there a child class, a parent class. 39 00:03:09,730 --> 00:03:12,760 And also we have execution lines at the end. 40 00:03:13,390 --> 00:03:22,300 So we are basically going to take the code, the answers code from that homework assignment and divide 41 00:03:22,300 --> 00:03:31,150 the content of that module into three separate modules if you came up with the resolution by yourself. 42 00:03:31,300 --> 00:03:35,920 So apply the following theme that we're going to talk about on your resolution. 43 00:03:36,370 --> 00:03:43,030 If you had some trouble and you don't have the resolution for it, just go back to the resolution video 44 00:03:43,180 --> 00:03:47,110 off inheritance in object oriented programming. 45 00:03:47,680 --> 00:03:49,810 I think it was the previous lecture. 46 00:03:50,080 --> 00:03:53,260 And you can have you can get the attachment file. 47 00:03:53,350 --> 00:04:00,130 You have an attachment file of P y file, which is a python file, and you can just copy its content 48 00:04:00,160 --> 00:04:04,150 or imported into your picture and then you would have the code. 49 00:04:04,600 --> 00:04:10,030 And upon this code, we're going to do some manipulations and changes right now. 50 00:04:12,990 --> 00:04:19,440 So basically, I'm going to talk about Feary right now, and a few seconds after we'll finish this slide, 51 00:04:19,630 --> 00:04:25,230 I'm going to open by charm and see show it to you in a live example. 52 00:04:25,500 --> 00:04:25,890 All right. 53 00:04:26,950 --> 00:04:34,510 So basically, we had their one module, which had employee class and which was the parent, and also 54 00:04:34,510 --> 00:04:36,870 we had a program, a class which was the child. 55 00:04:37,150 --> 00:04:41,560 And at the end, we have we had an instance of an object, two of them. 56 00:04:41,860 --> 00:04:46,660 And for each one of these instances, we have executed several methods. 57 00:04:46,740 --> 00:04:52,360 OK, this is the whole content that we had in the homework assignment of inheritance. 58 00:04:52,750 --> 00:04:59,140 And we're going to take this content in separate, separated two, three separate modules. 59 00:04:59,170 --> 00:05:09,760 OK, so first of all, what are we going to do is to open PI charm and create three modules with these 60 00:05:09,760 --> 00:05:10,210 names? 61 00:05:10,240 --> 00:05:17,230 OK, as we're speaking, you can do it and apply what I am teaching now in your pie charm. 62 00:05:17,500 --> 00:05:21,790 And as I just said, I'm going to show you at the end how to do it. 63 00:05:22,030 --> 00:05:28,270 But if you are willing and you want it so you can apply what I'm seeing right now as I'm speaking in 64 00:05:28,270 --> 00:05:28,950 your pichon. 65 00:05:29,860 --> 00:05:32,740 So you need to create these three modules, right? 66 00:05:33,280 --> 00:05:37,350 Import, parent class, import class and import execution. 67 00:05:38,320 --> 00:05:43,120 Once you have these three files, please paste into the import bank class. 68 00:05:43,570 --> 00:05:55,000 All the content that you had off employee class from these homework, all what appears inside the employee 69 00:05:55,000 --> 00:05:58,480 class, just paste it into this class and into this module. 70 00:05:58,570 --> 00:06:07,840 OK, the class, the unique method, all the classes, method import, all of that into this module. 71 00:06:07,870 --> 00:06:08,800 Simple as that. 72 00:06:09,070 --> 00:06:18,040 Can you use copy paste then go over to the programming class, which is much smaller and copy all of 73 00:06:18,040 --> 00:06:22,630 the programming class content into this module. 74 00:06:24,460 --> 00:06:32,350 And once you finish, then go to the bottom of the page where you have the creation instead of instances 75 00:06:33,220 --> 00:06:34,780 of these classes. 76 00:06:35,000 --> 00:06:42,820 Yeah, and you have also the execution of the methods and copies of all of that content, all the execution 77 00:06:42,820 --> 00:06:45,250 parts into this module. 78 00:06:46,330 --> 00:06:46,710 All right. 79 00:06:46,720 --> 00:06:55,720 So now we have basically breakdown breaking down the the homework into three separate classes. 80 00:06:56,170 --> 00:06:59,980 And now I'm just going to show you exactly what I meant. 81 00:07:00,130 --> 00:07:02,770 OK, so copy all of this. 82 00:07:06,630 --> 00:07:15,000 Place it in one module, right, then copy all of this, place it to the second module, not I'm not 83 00:07:15,000 --> 00:07:23,250 sure it's the second, but place it in the child import child and then copy all of this and place it 84 00:07:23,250 --> 00:07:24,750 in the execution module. 85 00:07:25,320 --> 00:07:25,830 All right. 86 00:07:26,580 --> 00:07:27,660 Now let's continue. 87 00:07:29,880 --> 00:07:37,490 Each of these in each of the above marked modules, we would find an error or write an error is indicated 88 00:07:37,700 --> 00:07:42,020 by a red line which will appear below a certain phrase. 89 00:07:42,130 --> 00:07:45,130 OK, it's like it's like a line that goes like this. 90 00:07:45,140 --> 00:07:47,240 UPS and downs, ups and downs, red line. 91 00:07:47,510 --> 00:07:53,500 And you can find in these two marked modules and error inside them. 92 00:07:53,960 --> 00:07:54,530 All right. 93 00:07:55,430 --> 00:07:57,980 And now we'll try to resolve these errors. 94 00:07:58,010 --> 00:08:01,540 OK, so first of all, we're going to discuss import child class. 95 00:08:03,350 --> 00:08:04,880 That's the program. 96 00:08:04,880 --> 00:08:05,570 Our class. 97 00:08:05,570 --> 00:08:10,460 Yeah, that's the class that will contain the programer. 98 00:08:10,510 --> 00:08:10,850 Right. 99 00:08:12,820 --> 00:08:23,620 So we have an area there basically that that indicates we have an error in the in the declaration line 100 00:08:23,620 --> 00:08:29,130 of the class, we have their class programer and in brackets we have employee. 101 00:08:29,290 --> 00:08:31,960 So under the law, the employee, we have a red line. 102 00:08:32,290 --> 00:08:33,340 This indicates an error. 103 00:08:33,730 --> 00:08:35,440 OK, so let's follow these steps. 104 00:08:35,830 --> 00:08:39,850 So first of all, click on the word with the red line below it. 105 00:08:40,150 --> 00:08:43,660 Then you would see a red ball because it appears to your left. 106 00:08:43,990 --> 00:08:50,320 Click on it, then you'll have a pop up menu opens and you will have imposed this name. 107 00:08:50,320 --> 00:08:57,430 So click on empathies name and then please import the line that says. 108 00:08:58,430 --> 00:09:03,650 Import bearing class, that employee, and before you click it. 109 00:09:04,310 --> 00:09:12,460 What we're basically doing is, all right, we're importing from import paned glass. 110 00:09:12,950 --> 00:09:15,020 This is the name of the module. 111 00:09:15,830 --> 00:09:17,150 And then we have DOT. 112 00:09:18,500 --> 00:09:25,070 And then we have an employee, employee is the name of the class that we we're importing, we have an 113 00:09:25,070 --> 00:09:27,190 air or below the war, the employee. 114 00:09:27,590 --> 00:09:33,950 So now we're importing employee what basically is missing for this module. 115 00:09:34,100 --> 00:09:40,010 And once you click on the import button on the what you're going to import, you would see suddenly 116 00:09:40,010 --> 00:09:47,660 an import line is added to the top of your module and it says exactly what import we have just submitted. 117 00:09:48,230 --> 00:09:53,180 And you can see the red line below the employee word gun. 118 00:09:54,080 --> 00:09:58,310 So we have resolved the arrow that we had in this module. 119 00:09:58,580 --> 00:10:10,720 And basically what we did is, is we connected the the import child class module with the import parent 120 00:10:10,730 --> 00:10:11,610 class module. 121 00:10:12,240 --> 00:10:23,330 OK, we have connected these two and now once we are trying to inherit in program a class from employee 122 00:10:23,330 --> 00:10:30,380 class, now we have this import command which which connects these two classes in these two modules, 123 00:10:30,710 --> 00:10:35,030 and now they can like sort of speak discuss between them. 124 00:10:35,030 --> 00:10:37,320 They can trade data between them. 125 00:10:38,690 --> 00:10:41,390 OK, so we have the same error. 126 00:10:41,390 --> 00:10:46,020 We have the same type of error actually in the import and execution file. 127 00:10:46,400 --> 00:10:56,330 OK, where we pasted all of our lines of creation of an instance and an execution of methods, all of 128 00:10:56,330 --> 00:10:58,060 that will appear there. 129 00:10:58,520 --> 00:11:03,760 So there we have an error below the class name programmer. 130 00:11:03,920 --> 00:11:10,970 OK, this module does not recognize the word programmer, which is a name of a class who does not know 131 00:11:11,180 --> 00:11:12,260 what that is. 132 00:11:13,310 --> 00:11:17,240 So what we're going to do is, again, click on the red. 133 00:11:18,420 --> 00:11:24,900 Click on the red ward that has this error, then you have the right bulb sometimes after clicking on 134 00:11:24,900 --> 00:11:30,990 the word, it takes up to two, one or two seconds for the bulb to appear, then click on the bulb, 135 00:11:30,990 --> 00:11:40,830 click, import this name and then import are where you have the name, import child glass, dot programer 136 00:11:41,640 --> 00:11:42,300 once you click. 137 00:11:42,300 --> 00:11:50,850 And that also an import line will be added to your top of your petroleum model file and you could see 138 00:11:50,850 --> 00:11:51,900 the error is gone. 139 00:11:53,070 --> 00:11:53,580 All right. 140 00:11:54,300 --> 00:12:01,590 Now let's go to example of what we have just discussed and it will take only a few seconds because actually 141 00:12:01,590 --> 00:12:04,020 it's a small topic, but it's very important. 142 00:12:04,110 --> 00:12:04,560 All right. 143 00:12:04,890 --> 00:12:07,830 If you want to become professional programmers, this is very important. 144 00:12:09,030 --> 00:12:10,050 So this is the error. 145 00:12:10,050 --> 00:12:16,640 Just clicking on it, then I'm having here the bulb, then clicking on this name and then I can see 146 00:12:16,650 --> 00:12:19,220 here import class employee. 147 00:12:20,040 --> 00:12:20,520 All right. 148 00:12:20,530 --> 00:12:21,420 So I clicked on it. 149 00:12:21,420 --> 00:12:23,220 You see, the error is going on here. 150 00:12:23,430 --> 00:12:27,390 And you can also see that this import line is added to the top. 151 00:12:27,780 --> 00:12:37,140 And if you hold your control, file a control button and click with your mouse on this loop, you can 152 00:12:37,140 --> 00:12:40,370 see I'm redirected to the import ban class. 153 00:12:42,030 --> 00:12:42,380 Yeah. 154 00:12:42,390 --> 00:12:44,500 So these two are connected now. 155 00:12:44,580 --> 00:12:50,940 OK, so you can see that this line right here tells to the module what this means. 156 00:12:52,870 --> 00:12:59,600 And the we were going to the execution file import execution, we can see an error here as well. 157 00:12:59,860 --> 00:13:06,790 Same resolution, click on the error ward, then click on the bulb for this name and then just import 158 00:13:07,030 --> 00:13:10,750 childless dot programmer and brackets employee. 159 00:13:12,260 --> 00:13:20,570 OK, so you can see the important edit here and the arrow is gone, OK, it's all nice and good, but 160 00:13:21,330 --> 00:13:22,150 it's all gone. 161 00:13:22,200 --> 00:13:24,070 It all comes down to business. 162 00:13:24,290 --> 00:13:27,680 It all comes down if this would run or not. 163 00:13:27,980 --> 00:13:30,770 So right now we are marked. 164 00:13:31,370 --> 00:13:34,370 Add the import execution file right here. 165 00:13:34,610 --> 00:13:41,780 Let's just try to run it and see if this whole import thing works and if these three one, two, three 166 00:13:42,080 --> 00:13:44,840 modules can actually discuss between themselves. 167 00:13:44,870 --> 00:13:48,740 All right, Ron, there you have it. 168 00:13:49,430 --> 00:13:49,820 All right. 169 00:13:49,820 --> 00:13:50,600 There you have it. 170 00:13:50,870 --> 00:13:54,290 So right here, you can see the execution running perfectly. 171 00:13:54,530 --> 00:14:02,630 And these three, OK, these three files, one, two, three are communicating perfectly the understanding 172 00:14:02,630 --> 00:14:06,800 each other and their spacing data among and between them. 173 00:14:07,280 --> 00:14:16,100 So I think this covers the part of import, basically, at least what I've encountered. 174 00:14:16,310 --> 00:14:23,440 I know that all project in professional programming in I.T. companies always and I've seen lots of project. 175 00:14:23,450 --> 00:14:23,810 All right. 176 00:14:23,990 --> 00:14:26,270 I see I've seen CRM projects. 177 00:14:26,270 --> 00:14:29,000 I've seen professional website projects. 178 00:14:29,000 --> 00:14:31,460 I've seen automation projects, you name it. 179 00:14:31,730 --> 00:14:34,850 All of them are structured in a certain way. 180 00:14:35,000 --> 00:14:39,260 They have dozens of files in these files are talking between them. 181 00:14:39,260 --> 00:14:39,530 All right. 182 00:14:39,530 --> 00:14:44,660 So you need to be familiar with this important keyword and how how does it work? 183 00:14:44,930 --> 00:14:51,050 And basically, each project, the team leader arranges the files in a logical way. 184 00:14:51,320 --> 00:14:54,710 OK, like metaphorically if you have food. 185 00:14:54,710 --> 00:15:05,480 So you would have a module for fruits, a module for meats like meat, food and different file for, 186 00:15:05,750 --> 00:15:06,860 I don't know, Candie's. 187 00:15:06,880 --> 00:15:07,280 Right. 188 00:15:07,370 --> 00:15:12,890 So you can't have a mix of all of them because you could not understand the meaning of this file. 189 00:15:13,460 --> 00:15:13,970 All right. 190 00:15:14,180 --> 00:15:17,810 It's like a metaphor, but it explains the idea perfectly. 191 00:15:17,990 --> 00:15:26,720 So you would need to understand this import keyword in order to have the ability to separate your information, 192 00:15:26,720 --> 00:15:30,830 your data, and to place it in the right place in your project. 193 00:15:30,950 --> 00:15:38,090 So other teammates will also could follow your steps once you created some code and understand what 194 00:15:38,090 --> 00:15:42,560 you did so you won't have a mix of things in the same file. 195 00:15:43,320 --> 00:15:46,670 OK, this summer, the import lecture. 196 00:15:46,790 --> 00:15:49,580 Thank you for listening and I'll see you in the next lecture.