4 ms·
I don't think it's clever, it's quite unintuitive and ugly. To me anyway. If the author really wanted to cram everything into a list comprehension, the logical
by jotaass 3y ago
I don't think it's clever, it's quite unintuitive and ugly. To me anyway. If the author really wanted to cram everything into a list comprehension, the logical way to think about it is:
(
(int(tsc, 16), int(pc, 16))
for tsc, _, pc, *_ in (line.strip().split(",") for line in fp)
),
Which is, of course, almost as ugly. Just use a for loop and yield
- bombela 3y agoRight, I should have said clever code golf. I think I would have written it like that: def parse(line): p = line.split(",") return ((int(p[0], 16), int(p[2], 16)) (parse(line)) for line in fp) And when it was still cool: map(parse, fp)