On Tue, Sep 10, 2013 at 10:09 AM, Noufal Ibrahim <nou...@nibrahim.net.in>wrote:
> Shabda Raaj <sha...@agiliq.com> writes: > > >> I generally like to use attributes instead of keys. > > > > If you are parsing json, aren't you limited to using keys? > > Of course. I was making a general statement about attributes vs. keys. > > > The bunch pattern can fix this, but its not widely known/used, so I > > don't use it as frequently as I would like. > > Yes. It's quite neat. > web.py has something similar, but it works both like a dict and object at the same time. More like a javascript object. https://github.com/webpy/webpy/blob/master/web/utils.py#L52 Couple of issues with the Bunch pattern: * it is hard to check for existence of a key * hard to iterate over the keys * how do you convert a bunch object into JSON? Anand _______________________________________________ BangPypers mailing list BangPypers@python.org https://mail.python.org/mailman/listinfo/bangpypers