Let's talk about multiple inheritance, which you're able to do in Python.
Now, remember, we have our user wizard and archer classes.
We're trying to build that game right now.
Let's clean up some of this code.
We won't need the init function anymore.
We'll just have user here.
We have wizard that inherits from user and also archer that inherits from user.
But what happens if we want to create a new character and this character is called a class, let's say.
Let's say it's called hybrid Borg or we are name.
I know.
But here's the thing.
Hybrid Borg is a special type of character because it has the powers that wizards have, which is attack.
It has the power that archers have, which is Czech arrows.
And just for fun, let's also ad run here.
And we'll just say four run ran really fast.
All right.
So we want this hybrid Borg to have all of these methods.
Can we do that?
Well, we can.
All we need to do is say Wizard and then Archer.
We can give it as many parameters as we want as.
As multiple inheritances we're inheriting from Wizard and Archer.
So that in here, let's say I don't do anything and I'll just hit pass.
If I instantiate, let's say hybrid Borg.
One is going to be hybrid.
Borg class instantiate it.
I can now use all of these things.
Let's check them.
Let's say print HP one dot run.
Can I do that?
And again, a little spelling error.
Let's make sure it's hybrid hybrid Borg, not hybrid board.
I hope you're not bored of this video.
All right, I get an error.
Missing two required positional arguments.
Name and power.
All right, because.
Well, we have to pass these things in.
Right.
It accepts these parameters.
Okay.
So let's say that we want a name to be.
Borghi and the power to be 50 if I Run This.
All right.
It looks like Ran really fast.
Run works.
I was able to inherit from Archer.
What about Czech arrows?
If I click Run.
Oh.
I get hybrid borg.
Object has no attribute arrows.
Now.
Why is that?
Because technically we.
Inherited from Wizard first, then Archer and Wizard accepts.
Name and power.
But we never gave the arrows, name and arrows.
Hmm.
So how can we solve that?
Let's try something.
Let's say we added arrows here.
100 with this work.
Hmm.
That doesn't work, does it?
And this is a tricky thing with multiple inheritance and why some programming languages actually don't
even allow multiple inheritance.
Things can get a little tricky because in your head, you have to make sure that you understand how
these classes are implemented and make sure that we're not overwriting anything.
In our case, we can complicate our code a little bit.
So what can we do here?
Well in here, I can perhaps do something like this.
I can say define in it.
This receives self.
It will receive a name a power.
And also.
Arrows.
And then finally in here, I can say that we're going to call also the Archer.
Dot in it.
And that's going to take sell off and then pass in the name.
And arrows.
So that if I run this.
Well, let's add the arrows 100 here and I click run.
There you go.
Arrows is now working.
Now just to check that our attack on the wizard is working as well.
If we do attack.
And Click Run.
Oh, boy.
Now our hybrid object has no power.
So once again, in order for us to have power, we'll have to copy this and let's say this time wizard
in it self and then give it power.
If I click Run.
All right.
Attack works.
Let's go back to check Aero.
Make sure we haven't broken anything.
If I click that, that works as well.
And then finally, what about sign in?
Well, sign in work.
Logged in.
All right.
Oh, boy.
That was a lot.
And there are a few ways of actually solving this problem.
What I wanted to show you, though, is that when you do multiple inheritance, things can get complicated.
And although we walk through it step by step, imagine if there was a coder that came along on your
team at work and tried to understand this code.
We've added quite a bit of logic here and things are getting more and more complicated and it's hard
to keep track of everything in your head.
And this is why multiple inheritance is one of those things where it's really, really powerful, but
with great power comes great responsibility because we're creating more and more complexity.
Again, part of the reason that some programming languages don't actually allow you to do multiple inheritance.
And by the way, I'm going to confuse you even more.
And the next video, we're going to talk about something called Maro.
And it's going to be another great example of why you want to be cautious with multiple inheritances.
I'll see you in that one.
Bye bye.