On Nov 2, 2011, at 10:15 PM, Magnitus wrote:

> I agree.
> 
> s.a is not sufficient if you want to avoid code repetition.
> 
> You'll naturally want use something like s['a'] at some point if you
> want to write good code and you will also want to rely on the
> convenient "returns None instead of throwing an exception" facility.
> 
> There are workarounds for this (personally, I just wrote a wrapper
> class to go around it so that I could use a natural dictionary
> notation with keeping the None behavior).
> 
> As part of your mandate is to support backward compatibility, someone
> probably relies on that peculiarity at this point, so you are stuck
> with the behavior of s['a'] throwing an exception the way it is now.
> 
> Perhaps just make sure the behavior of the storage object is properly
> documented so that it doesn't catch new people off guard.
> 
>> Still, it'd make sense for s['a'] to have the same semantics as s.a.

I'm of two minds on classes like Storage. In my non-web2py work I stick with 
dict, using dict.get and dict.setdefault where appropriate. But web2py has a 
lot of Storage objects floating around...

Reply via email to