[pkg-apparmor] UDD notifications script

intrigeri intrigeri at debian.org
Sun Mar 1 21:25:59 UTC 2015


Christian Boltz wrote (01 Mar 2015 19:51:02 GMT) :
> Am Sonntag, 1. März 2015 schrieb intrigeri:
>> I believe that using a list comprehension like (untested):
>> 
>>     return [ {'id': item[0], 'tag': item[1], 'title': item[2]}
>>              for item in items ]
>> 
>> (cute, isn't it?)
>> 
>> ... would be more Pythonic than:
>> 
>>     buglist = []
>>     for item in items:
>>         bug = {'id': item[0], 'tag': item[1], 'title': item[2]}
>>         buglist.append(bug)
>> 
>>     return buglist
>> 
>> I think I would even get rid of the items temporary variable, and
>> instead write:
>> 
>>     return [ {'id': item[0], 'tag': item[1], 'title': item[2]}
>>              for item in cursor.fetchall() ]

> More pythonic? Maybe.
> More readable and understandable? I slightly ;-) doubt

On the one hand, I'm curious if your opinion applies to the first,
slightly less dense version I've posted above. On the other hand,
perhaps this list isn't the best place for going *that* deep into
programming style debates -- especially when it basically boils down
to how much one likes declarative code that looks a math function
definition, vs. `for' loops that teach Python how to do the same :)

=> I'll let U. judge what she prefers to maintain. Both work for me.

Cheers,
-- 
intrigeri



More information about the pkg-apparmor-team mailing list