Why are local variable names beginning with an underscore discouraged?

Questions & AnswersCategory: PythonWhy are local variable names beginning with an underscore discouraged?
Lokesh Kumar Staff asked 2 years ago

Why are local variable names beginning with an underscore discouraged?
a. they are used to indicate a private variables of a class
b. they confuse the interpreter
c. they are used to indicate global variables
d. they slow down execution

1 Answers
Lokesh Kumar Staff answered 2 years ago

Answer: a
Explanation: As Python has no concept of private variables, leading underscores are used to indicate variables that must not be accessed from outside the class.