16
votes

We know that in a class, functions starting with __function__ do not get imported while using:

from module import *

Someone asked what is an _variable? I have never used one.
Do they exist? Is this a concept of variable which cannot be accessed using class object or something?

2

2 Answers

23
votes

It is a naming convention for private variables. See 9.6, private variables: http://docs.python.org/tutorial/classes.html#private-variables

7
votes

A variable name starting with an underscore is a strong hint that this variable should be viewed as private.

Read http://docs.python.org/tutorial/classes.html#private-variables