Standard behaviour of a getSomething method

Stefan Schwarzer sschwarzer at sschwarzer.net
Sat Jul 26 20:00:46 EDT 2003


John Roth wrote:
> "Stefan Schwarzer" <sschwarzer at sschwarzer.net> wrote in message
> news:bfulr8$5mi$1 at online.de...
>> Somewhat, I dislike the sometimes recommended __getattr__/__setattr__
>> approach. I wouldn't like to have something like
> 
> That sounds more than a bit heavyhanded to me. The more
> general practice is simply to name private attributes with a
> leading underscore. Then you can verify that there aren't any
> improper references by scanning the source for references to
> underscored variables that don't start with "self._".

I refered to public attributes here. For private (i. e. implementation-
specific) attributes I would just use the leading-underscore convention,
like you.

Stefan





More information about the Python-list mailing list