Welcome back. So, in this piece of code.
Here we set the instance variable for x for both point one and point two on lines 89.
Now, even though you can do this in your pipeline code,
this isn't the way that you should set instance variables.
So, instead you should set instance variables in what's called a constructor.
Now, a constructor is a special method that's meant to
initialize Python instances, including instance variables.
So, the constructor is named what's called
underscore underscore init underscore underscore.
It's just a special method with this name
underscore underscore init underscore underscore.
Now, I'm going to call this instead
of underscore underscore I'm going to say dunderscore.
So, that we'd make this dunderscore init dunderscore.
But instead of saying dunderscore init dunderscore.
I'm just going to say dunderscore init for now.
So, we want to define our constructor dunderscore init.
So, the way that we do that is we define this method and we can say def
dunderscore init dunderscore and init
just like every other method takes in self as its first argument.
I'm going to pass in two more arguments x and y.
Now, in our constructor,
I'm going to say self.x equals x,
and self.y equals y.
Now, if I delete these lines and try to run my code as this.
Then I'm going to get a run-time error,
saying that my constructor method takes
exactly three arguments but only one was given on line nine.
What that's saying is that,
so it takes three arguments but self was already provided when we called our constructor.
We need to pass in values for x and y as soon as we create instances of point.
So, here I'm going to pass in values five and 10 for this point,
and one and two for point two.
Now what happens here is that for point one,
I'm passing five in for x and 10 in for y.
For point two, I'm passing one in for x and two in for y.
Rather than setting the instance variables later on,
then what we're doing is we're setting the instance variables in this constructor.
So, when we say self.x equals x for point one,
that's setting point one.x to be five and point one.y to be 10.
When we do this for point two then we're setting point two.x to be point two.y to be two.
So, now if I call get x on point one,
so print point one.get x.
Then I should get five.
If I print out point two.get x,
then I should get one.
That's all for now until next time.