WEBVTT

00:00.490 --> 00:02.280
Constructor in a Function

00:06.990 --> 00:16.220
constructor in function init function is a built in function in Python and it's in the constructor of

00:16.220 --> 00:22.120
the class constructor is called whenever a new object of the class is created.

00:22.190 --> 00:31.280
And it should be called only during creating the object so promotor in the inner function refers to

00:31.280 --> 00:34.700
that instance for the object itself.

00:34.700 --> 00:40.210
And it's important to use it if you want to use a constructor in your class.

00:41.330 --> 00:42.730
Let's see how.

00:43.290 --> 00:43.760
OK.

00:43.820 --> 00:47.130
First go to.

00:50.450 --> 00:53.780
As you can see we have a class person.

00:53.780 --> 00:58.560
Now I will show you how to use the constructor of the class type.

00:58.590 --> 01:10.390
Def underscore underscore enet underscore underscore parenthesis self name age ID number call an event

01:10.390 --> 01:19.100
self that name equal name cells that age equal age so the ID number equal ID number or ID number whatever

01:19.820 --> 01:24.080
next type or output function.

01:45.560 --> 01:52.480
Ok now we are in the meaning of the program to use the constructor of the class create an object such

01:52.480 --> 01:56.810
as Jonni or person parenthesis quotation marks.

01:56.840 --> 02:02.050
John 33 on put the ID numbers.

02:02.050 --> 02:09.280
All right so doing creating the object we passed the arguments to the constructor of the class

02:14.280 --> 02:18.120
then type John the output function after that.

02:18.120 --> 02:27.170
Try that on terminal.

02:28.220 --> 02:29.300
Really nice.

02:29.300 --> 02:31.760
The constructor of the class works well.

02:32.090 --> 02:33.740
Thank you for watching.
