Why is my python so ugly

Question from Leslie#7406

FRR = map(lambda element: element[1], read_csv)
FAR = map(lambda element: element[2], read_csv)

why is this so ugly

Use operator.itemgetter(1), thats what it is for. Also a list comprehension is nicer usually.

make an example out of my code pls

FRR = map(operator.itemgetter(1), read_csv)

But then also

FRR = [ element[1] for element in read_csv ]

But then also

FRR, FAR = zip(*[ (element[1], element[2]) for element in read_csv ])

idk Ive never seen a zip(* [ before

* is a splat. It unrolls an iterable into arguments.


<- Index