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

Popular posts from this blog

c# - SharpSVN - How to get the previous revision? -

c++ - Is it possible to compile a VST on linux? -

url - Querystring manipulation of email Address in PHP -