Python: Split, strip, and join in one line
- by PandemoniumSyndicate
I'm curious if their is some python magic I may not know to accomplish a bit of frivolity
given the line:
csvData.append(','.join([line.split(":").strip() for x in L]))
I'm attempting to split a line on :, trim whitespace around it, and join on ,
problem is, since the array is returned from line.split(":"), the
for x in L #<== L doesn't exist!
causes issues since I have no name for the array returned by line.split(":")
So I'm curious if there is a sexy piece of syntax I could use to accomplish this in one shot?
Cheers!