Best way to control assignment to attribute?

wes weston wweston at att.net
Wed Feb 4 14:43:23 EST 2004


Aahz,
     He might be more interested in naming his class vars
with two leading underscores. eh? This mangles the name
making it not as it appears in the text and not accessible
by the expressed name. Does not the __slots__ statement
keep "you" from creating a new unintended class var?
wes

Aahz wrote:
> In article <XF9Ub.175053$6y6.3406052 at bgtnsc05-news.ops.worldnet.att.net>,
> wes weston  <wweston at att.net> wrote:
> 
>>Frank Millman wrote:
>>
>>>I want to control the assignment of a value to an attribute. Instead
>>>of allowing it to be changed directly, I want to enforce that a method
>>>is called, which will perform the assignment subject to various
>>>checks.
>>
>>   See __slots__; not sure if there's a newer/better way.
> 
> 
> You should be certain before even thinking of suggesting __slots__.
> __slots__ is intended only to save memory; there are many problems with
> using it if you don't know what you're doing.




More information about the Python-list mailing list