Object Oriented Programming Flashcards
1
Q
What is __init__?
A
It is an initialiser, not a constructor.
It takes self as an argument (so it exists already) and populates it.
2
Q
What is @classmethod used for?
A
Alternative constructor
3
Q
What is @staticmethod used for?
A
Attaching functions to classes - not a part of class but a utility
4
Q
What is purpose of using double underscore before variable name?
A
Distinguish class and subclass variable _class\_\_var