Changing the private variables content

Rhodri James rhodri at wildebst.demon.co.uk
Tue Jul 21 18:00:39 EDT 2009


On Tue, 21 Jul 2009 21:55:18 +0100, Ryniek90 <ryniek90 at gmail.com> wrote:

> Hi.
> I'm writing some class, and decided to use inside private method and  
> some private variables. While with method i haven't got any problem's  
> with variables i have.

There is no mechanism in Python that makes attributes truly private.
self._number is an attribute just like any other, the whole business
with _leading_underscores is purely a matter of convention.  If you
have an instance attribute or method with a leading underscore, you
know that using it or calling it isn't something you're supposed
to do outside its class, but nothing will stop you doing exactly that
if you're rude enough to try.

Does that help?

-- 
Rhodri James *-* Wildebeest Herder to the Masses



More information about the Python-list mailing list