On Oct 27, 2011, at 5:03 PM, Jonathan Lundell wrote: > On Oct 27, 2011, at 10:57 AM, Massimo Di Pierro wrote: > >> Any suggestion for improvement? > > I'm not sure when I'll have time to get around to it, but my idea is to > implement both Storage.__getattr__ and .__getitem__ in terms of > super(get(whatever, None)). (That's not quite the syntax, but you get the > idea.) I don't suppose that __setattr__ needs any special attention.
__setitem__, I meant. > >> >> On Oct 25, 3:32 pm, Jonathan Lundell <jlund...@pobox.com> wrote: >>> On Oct 25, 2011, at 1:18 PM, Anthony <abasta...@gmail.com> wrote: >>> >>>> On Tuesday, October 25, 2011 4:08:20 PM UTC-4, pepper_bg wrote: >>>>> You can do >>>>> s.get(6,None) >>> >>>> Still have to anticipate what my keys are and write different code >>>> accordingly. Which is fine in most cases I guess. Or may be I am >>>> trying to be too generic here. Thanks for your input... >>> >>>> If you're not sure whether a key might be a string or integer, you can use >>>> the s.get() method in all cases. >>> >>> Still, it'd make sense for s['a'] to have the same semantics as s.a. > >