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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What is @classmethod used for?

A

Alternative constructor

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What is @staticmethod used for?

A

Attaching functions to classes - not a part of class but a utility

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What is purpose of using double underscore before variable name?

A
Distinguish class and subclass variable
_class\_\_var
How well did you know this?
1
Not at all
2
3
4
5
Perfectly