InterviewSolution
Saved Bookmarks
| 1. |
What is init in Python? |
|
Answer» ‘init’ basically stands for initialization. The role of init is to create processes from the script stored in the file which is a configuration file. This is then to be USED by the initialization system. The __init__ method is similar to constructors in C++ and Java. Example: # init method or constructor def __init__(self, name): self.name = nameIn the above example, the name passed as an ARGUMENT will be passed to the __init__ method to initialize the OBJECT. The keyword self represents the instance of a class and BINDS the attributes with the GIVEN arguments. |
|