5 ms·
What does the equivalent code in the latest version of Python look like?
by altano 17y ago
What does the equivalent code in the latest version of Python look like?
- EliAndrewC 17y agocontactRecords = [r for r in contactRecords if r[1] == "1"]
- adw 17y agoAnd in reasonably idiomatic recent Python, the whole thing'd be: #!/usr/bin/env python import fileinput import csv EMAIL, CONTACTME, SKUTITLE = 17, 27, 34 tsl = csv.reader(fileinput.input(), dialect='excel-tab') for line in sorted([r[SKUTITLE], r[CONTACTME], r[EMAIL]] for r in tsl if r[CONTACTME] == "1"): print "\t".join(line) It's going to be good in any language though, isn't it?