[Tutor] Underscores
Sean 'Shaleh' Perry
shalehperry@attbi.com
Tue, 19 Mar 2002 14:02:35 -0800 (PST)
On 19-Mar-2002 shendric@arches.uga.edu wrote:
> Greetings all,
>
> This is probably a really boring question, but I've been looking at some
> code and there are a number of cases where the method name is prefixed
> with and underscore (self._hull, etc.). Now, I understand the use of
> the underscore in __init__, but does the underscore like that above
> serve a purpose? In that particular code, I can't find a function that
> is defined as _hull. Just to be clear, this code is used to configure a
> MegaWidget in Tkinter, and I know that hull is an option for a
> MegaWidget, but I've never seen _hull.
>
a leading underscore says 'I am private, leave me alone'. It is analogous to
placing the variable in the private section of a C++ or Java class definition,
although in python the privateness is a convention and only loosely enforced.