One liners

Chris Angelico rosuav at gmail.com
Sat Dec 7 05:06:00 CET 2013


On Sat, Dec 7, 2013 at 2:27 PM, Roy Smith <roy at panix.com> wrote:
> --------------------------------------------------
> extracols = sorted(set.union(*(set(t.data.keys()) for t in tracks))) if
> tracks else []
> --------------------------------------------------
> c2s = compids2songs(set(targets.keys()) |
> set.union(*map(set,targets.itervalues())),self.docmap,self.logger) if
> targets else {}

Easy rewrites:

extracols = tracks and sorted(set.union(*(set(t.data.keys()) for t in tracks)))

Assumes that tracks is a list, which it most likely is given the
context. Parallel with the other.

ChrisA



More information about the Python-list mailing list