[pkg-apparmor] UDD notifications script
Christian Boltz
apparmor-debian at cboltz.de
Sun Mar 1 19:51:02 UTC 2015
Hello,
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
> Similarly:
>
> for item in new_state_data:
> if item not in old_state_data:
> added_usertags.append(item)
>
> ... could be made more declarative, if you fancy declarative code (as
> opposed to procedural one) as much as I do:
>
> added_usertags = [ item for item in new_state_data
> if item not in old_state_data ]
>
> (same for deleted_usertags)
Same comment here ;-)
Regards,
Christian Boltz
PS: Non-random sig, and please make sure not to invalidate Keith's
statement with interesting[tm] python code ;-)
--
Perl - the only language that looks the same before and after RSA
encryption. -- Keith Bostic
More information about the pkg-apparmor-team
mailing list