automatic accessors to a member var dict elements?

Jeff Shannon jeff at ccvcorp.com
Fri Oct 15 20:23:03 CEST 2004


Bengt Richter wrote:

>On Thu, 14 Oct 2004 17:56:09 -0700, Jeff Shannon <jeff at ccvcorp.com> wrote:
>[...]
>  
>
>>One problem with the way I'm doing things here is that, if you set a 
>>dict item to a value of None, the object will raise an AttributeError 
>>when trying to access that item.  This really ought to use a safer 
>>sentinel value.  (Check for a recent thread here in c.l.py about 
>>sentinel values and the use of object() as one.)
>>
>>    
>>
>Why not (untested) avoid the default sentinel and just translate
>a key error to an attribute error as above?
>  
>

Good point -- that makes this safer, cleaner, and more Pythonic.  :)

Jeff Shannon
Technician/Programmer
Credit International




More information about the Python-list mailing list