I want to see all the variables

Steven D'Aprano steve at REMOVE.THIS.cybersource.com.au
Sat Dec 30 21:56:20 EST 2006


On Sun, 31 Dec 2006 03:39:52 +0100, Rene Fleschenberg wrote:

> johnf wrote:
>> Very detailed.  But I was attempting to debug some code which subclassed
>> other code. I got a traceback that something like "no
>> mySubClass.__source.query() did not exist".  
> 
> By (strong) convention, "__" means "not to be accessed from outside the
> class, not even from subclasses". The author of the original class does
> not want you to access that attribute.

What does the author of the original class know about *my* needs and
requirements? It may turn out that accessing his "private" attributes is
exactly what I need to solve my problem.

I'm with the Python philosophy on this one: post all the "Don't Touch
This" warning signs you like, but if somebody really wants to access my
private attributes, to do something I never even imagined, they should be
allowed to. If they break something, well, that's their fault, not mine.
I'm 100% in favour of language features which protect people from
*accidentally* shooting themselves in the foot, but if somebody wants to,
who am I to say they mustn't?



-- 
Steven.




More information about the Python-list mailing list