How to automate accessor definition?

kj at
Mon Mar 22 23:16:09 CET 2010

In <4ba79040$0$22397$426a74cc at> Bruno Desthuilliers <bruno.42.desthuilliers at websiteburo.invalid> writes:

>kj a écrit :
>> PS: BTW, this is not the first time that attempting to set an
>> attribute (in a class written by me even) blows up on me.  It's
>> situations like these that rattle my grasp of attributes, hence my
>> original question about boring, plodding, verbose Java-oid accessors.
>> For me these Python attributes are still waaay too mysterious and
>> unpredictable to rely on.

>Somehow simplified, here's what you have to know:


>As I said, this is a somehow simplified description of the process - I 
>skipped the parts about __slots__, __getattribute__ and __setattr__, as 
>well as the part about how function class attributes become methods.
>this should be enough to get an idea of what's going on.

Thank you, sir!  That was quite the education.

(Someday I really should read carefully the official documentation
for the stuff you described, assuming it exists.)

Thanks also for your code suggestions.


More information about the Python-list mailing list