Object Oriented Programming

Instantiation in Python

Used to create an object instance from a class (instantiate).


Syntax
identifier = ClassName(passed_parameters)

Notes

Input requirements are taken from the constructor.

An instance of a class is called an object.


Example
#class definition
class Car
     def __init__(self, make):
         self.make = make

#class instantiation
myCar = Car("Honda")

< Constructor   |   Methods >

© 2019 SyntaxDB. All Rights Reserved.