Hi to all Piter ninja's, welcome to this video.
Now, once we have completed the parts, the main parts of our group, let's talk about a closer topic
and that would be important.
All right.
So up until this point, we have encountered a classes in the aspect of creating a class.
Doesn't matter if it's a parent and the child or even both, and executing that these methods of that
class using an instance in the same module.
But in real life, sometimes it's a bit different, OK, that some of you is going to apply and be accepted
into I.T. companies.
And over there, obviously, teams, development teams are not working on one file.
All right.
They're working on multiple files, maybe several hundred of files.
And these files are interacting all the time.
They're basing data from one file to another.
One file can execute other files and basically everything is possible.
So this is the topic that we're going to study today.
OK, the interaction between the files can be can be implemented by using a special special property
or special functionality that is called an import.
Right.
And this is what I'm going to talk about right now.
All right.
So let's begin.
So let's assume the following thing.
We're starting off working on a new project.
And in that particular project, we have classes.
The class or multiple classes will be held off in Module A by their execution, will be kept in a different
module and let's call it module B.
So basically what we are willing to achieve is, is to execute the class or classes methods by Module
B, but this Module B should recognize all the content that we have created in Module eight.
So there must be some kind of connection between them.
All right.
And these type of rules and these type of relationship between modules appear in every real project.
All right.
There that thing this relationship between modules can be achieved by the import keyword.
And this is what we're going to learn right now.
And let's see how to do it.
OK, this lecture, we're going to focus on the homework assignment that you had in an inheritance.
We have created there a child class, a parent class.
And also we have execution lines at the end.
So we are basically going to take the code, the answers code from that homework assignment and divide
the content of that module into three separate modules if you came up with the resolution by yourself.
So apply the following theme that we're going to talk about on your resolution.
If you had some trouble and you don't have the resolution for it, just go back to the resolution video
off inheritance in object oriented programming.
I think it was the previous lecture.
And you can have you can get the attachment file.
You have an attachment file of P y file, which is a python file, and you can just copy its content
or imported into your picture and then you would have the code.
And upon this code, we're going to do some manipulations and changes right now.
So basically, I'm going to talk about Feary right now, and a few seconds after we'll finish this slide,
I'm going to open by charm and see show it to you in a live example.
All right.
So basically, we had their one module, which had employee class and which was the parent, and also
we had a program, a class which was the child.
And at the end, we have we had an instance of an object, two of them.
And for each one of these instances, we have executed several methods.
OK, this is the whole content that we had in the homework assignment of inheritance.
And we're going to take this content in separate, separated two, three separate modules.
OK, so first of all, what are we going to do is to open PI charm and create three modules with these
names?
OK, as we're speaking, you can do it and apply what I am teaching now in your pie charm.
And as I just said, I'm going to show you at the end how to do it.
But if you are willing and you want it so you can apply what I'm seeing right now as I'm speaking in
your pichon.
So you need to create these three modules, right?
Import, parent class, import class and import execution.
Once you have these three files, please paste into the import bank class.
All the content that you had off employee class from these homework, all what appears inside the employee
class, just paste it into this class and into this module.
OK, the class, the unique method, all the classes, method import, all of that into this module.
Simple as that.
Can you use copy paste then go over to the programming class, which is much smaller and copy all of
the programming class content into this module.
And once you finish, then go to the bottom of the page where you have the creation instead of instances
of these classes.
Yeah, and you have also the execution of the methods and copies of all of that content, all the execution
parts into this module.
All right.
So now we have basically breakdown breaking down the the homework into three separate classes.
And now I'm just going to show you exactly what I meant.
OK, so copy all of this.
Place it in one module, right, then copy all of this, place it to the second module, not I'm not
sure it's the second, but place it in the child import child and then copy all of this and place it
in the execution module.
All right.
Now let's continue.
Each of these in each of the above marked modules, we would find an error or write an error is indicated
by a red line which will appear below a certain phrase.
OK, it's like it's like a line that goes like this.
UPS and downs, ups and downs, red line.
And you can find in these two marked modules and error inside them.
All right.
And now we'll try to resolve these errors.
OK, so first of all, we're going to discuss import child class.
That's the program.
Our class.
Yeah, that's the class that will contain the programer.
Right.
So we have an area there basically that that indicates we have an error in the in the declaration line
of the class, we have their class programer and in brackets we have employee.
So under the law, the employee, we have a red line.
This indicates an error.
OK, so let's follow these steps.
So first of all, click on the word with the red line below it.
Then you would see a red ball because it appears to your left.
Click on it, then you'll have a pop up menu opens and you will have imposed this name.
So click on empathies name and then please import the line that says.
Import bearing class, that employee, and before you click it.
What we're basically doing is, all right, we're importing from import paned glass.
This is the name of the module.
And then we have DOT.
And then we have an employee, employee is the name of the class that we we're importing, we have an
air or below the war, the employee.
So now we're importing employee what basically is missing for this module.
And once you click on the import button on the what you're going to import, you would see suddenly
an import line is added to the top of your module and it says exactly what import we have just submitted.
And you can see the red line below the employee word gun.
So we have resolved the arrow that we had in this module.
And basically what we did is, is we connected the the import child class module with the import parent
class module.
OK, we have connected these two and now once we are trying to inherit in program a class from employee
class, now we have this import command which which connects these two classes in these two modules,
and now they can like sort of speak discuss between them.
They can trade data between them.
OK, so we have the same error.
We have the same type of error actually in the import and execution file.
OK, where we pasted all of our lines of creation of an instance and an execution of methods, all of
that will appear there.
So there we have an error below the class name programmer.
OK, this module does not recognize the word programmer, which is a name of a class who does not know
what that is.
So what we're going to do is, again, click on the red.
Click on the red ward that has this error, then you have the right bulb sometimes after clicking on
the word, it takes up to two, one or two seconds for the bulb to appear, then click on the bulb,
click, import this name and then import are where you have the name, import child glass, dot programer
once you click.
And that also an import line will be added to your top of your petroleum model file and you could see
the error is gone.
All right.
Now let's go to example of what we have just discussed and it will take only a few seconds because actually
it's a small topic, but it's very important.
All right.
If you want to become professional programmers, this is very important.
So this is the error.
Just clicking on it, then I'm having here the bulb, then clicking on this name and then I can see
here import class employee.
All right.
So I clicked on it.
You see, the error is going on here.
And you can also see that this import line is added to the top.
And if you hold your control, file a control button and click with your mouse on this loop, you can
see I'm redirected to the import ban class.
Yeah.
So these two are connected now.
OK, so you can see that this line right here tells to the module what this means.
And the we were going to the execution file import execution, we can see an error here as well.
Same resolution, click on the error ward, then click on the bulb for this name and then just import
childless dot programmer and brackets employee.
OK, so you can see the important edit here and the arrow is gone, OK, it's all nice and good, but
it's all gone.
It all comes down to business.
It all comes down if this would run or not.
So right now we are marked.
Add the import execution file right here.
Let's just try to run it and see if this whole import thing works and if these three one, two, three
modules can actually discuss between themselves.
All right, Ron, there you have it.
All right.
There you have it.
So right here, you can see the execution running perfectly.
And these three, OK, these three files, one, two, three are communicating perfectly the understanding
each other and their spacing data among and between them.
So I think this covers the part of import, basically, at least what I've encountered.
I know that all project in professional programming in I.T. companies always and I've seen lots of project.
All right.
I see I've seen CRM projects.
I've seen professional website projects.
I've seen automation projects, you name it.
All of them are structured in a certain way.
They have dozens of files in these files are talking between them.
All right.
So you need to be familiar with this important keyword and how how does it work?
And basically, each project, the team leader arranges the files in a logical way.
OK, like metaphorically if you have food.
So you would have a module for fruits, a module for meats like meat, food and different file for,
I don't know, Candie's.
Right.
So you can't have a mix of all of them because you could not understand the meaning of this file.
All right.
It's like a metaphor, but it explains the idea perfectly.
So you would need to understand this import keyword in order to have the ability to separate your information,
your data, and to place it in the right place in your project.
So other teammates will also could follow your steps once you created some code and understand what
you did so you won't have a mix of things in the same file.
OK, this summer, the import lecture.
Thank you for listening and I'll see you in the next lecture.