[Tutor] What is the meaning of using single underscore in front ofvariable name

Alan Gauld alan.gauld at btinternet.com
Tue Nov 28 19:51:40 CET 2006

"Asrarahmed Kadri" <ajkadri at googlemail.com> wrote

> Single underscore as a prefix in variable naming...?? whats it for??
> Any idea..

Its a convention to indicate that this variable is not for general 
It is part of the internal implementation of the class or module.

But it is only a convention and Python will not stop you from
accessing it. It is similar to the convention of using all uppercase
letters to indicate a constant value that should not be changed
by users of the code.


Alan Gauld
Author of the Learn to Program web site

More information about the Tutor mailing list