A question of variables
M.-A. Lemburg
mal at lemburg.com
Fri Aug 20 04:04:17 EDT 1999
Carlos Ors wrote:
>
> How can I declare a variable as a private variable inside a method of a
> class?
All variables defined inside a method of a class are private to
that method except ones declared global with the global statement.
The same applies to functions.
"Private" instance attributes can be created using the __XXX
convention, e.g. self.__privatevar = 1. These are only
useable for methods defined in the same class, not for methods
defined in subclasses.
--
Marc-Andre Lemburg
______________________________________________________________________
Y2000: 133 days left
Business: http://www.lemburg.com/
Python Pages: http://www.lemburg.com/python/
More information about the Python-list
mailing list