[BangPypers] Favorite tips/techniques

Shabda Raaj shabda at agiliq.com
Tue Sep 10 07:09:36 CEST 2013


> https://github.com/webpy/webpy/blob/master/web/utils.py#L52

Wow, thats better than the "bare" bunch impl. Gonna use it now.

Unrelated tip:

Here is a one liner I use to generate passwords and other random strings.

''.join(random.choice(string.ascii_uppercase + string.digits) for x in
range(N))






On Tue, Sep 10, 2013 at 10:18 AM, Anand Chitipothu <anandology at gmail.com>wrote:

>
> On Tue, Sep 10, 2013 at 10:09 AM, Noufal Ibrahim <noufal at nibrahim.net.in>wrote:
>
>> Shabda Raaj <shabda at 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
>



-- 
Thanks,
Shabda

Agiliq.com - Building Amazing Apps
agiliq.com/blog/ | github.com/agiliq
US: +13152854388 | IN: +919949997612 | Skype: shabda.raaj
Our Android Apps <https://play.google.com/store/apps/developer?id=Agiliq> | Our
iOS Apps <https://itunes.apple.com/us/artist/agiliq/id407918088>


More information about the BangPypers mailing list