What is a convention to name a protected method in Python?
Experience Level: Junior
Tags: Python
Answer
The protected methods should be prefixed with single underscore.
Example:
def _add(x: int, y: int) -> int:
return x + y;
Related Python job interview questions
How do you pass an argument to a class constructor in Python?
Python JuniorHow do you define a constructor in a class in Python?
Python JuniorWhat is a convention to name a private method in Python?
Python JuniorHow do you communicate via code what argument types and what return value type a function has?
Python JuniorHow do you define a function in Python?
Python Junior