Multiple splits on a single line in Python -
i know if there more compact (or pythonic) way of doing several splits of input string. i'm doing:
[a,bc,de] = 'a,b:c,d/e'.split(',') [b,c] = bc.split(':') [d,e] = de.split('/')
i'd use regular expression library. don't need use lists unpacking, can use tuples below.
import re regex = re.compile(r'[,:/]') a, b, c, d, e = regex.split('a,b:c,d/e')
Comments
Post a Comment