[BangPypers] Favorite tips/techniques

Mandar Vaze / मंदार वझे mandarvaze at gmail.com
Tue Sep 10 11:11:20 CEST 2013


Both Shabda and Nouful used the term "prefer"
Is there a "best practice" ?

http://stackoverflow.com/questions/4984647/accessing-dict-keys-like-an-attribute-in-python

This guy asked for "pitfalls and caveats" - but no one seem to have
addressed the "question" (There are several answers about "How to do it
better")

-Mandar


On Tue, Sep 10, 2013 at 10:00 AM, Noufal Ibrahim <noufal at nibrahim.net.in>wrote:

> Shabda Raaj <shabda at agiliq.com> writes:
>
> >
> http://code.activestate.com/recipes/52308-the-simple-but-handy-collector-of-a-bunch-of-named/
> >
> > With api responses after you have parsed the json, you start doing things
> > like:
> >
> > api_response["attribute"]
> >
> > I would much prefer to do
> >
> > api_response.attribute
>
> I generally like to use attributes instead of keys. One additional
> advantage is that I can, if necessary, later convert the attribute into
> a property that does more than just return a value.
>
> [...]
>
>
> --
> Cordially,
> Noufal
> http://nibrahim.net.in
> _______________________________________________
> BangPypers mailing list
> BangPypers at python.org
> https://mail.python.org/mailman/listinfo/bangpypers
>


More information about the BangPypers mailing list