Split the string L at the character DELIM.
But don't split within groups nested in ([{}]) or in strings.
>>> split_list1 ('12345', ',')
['12345']
>>> split_list1 ('123, [45, 67], (89,[10,11],12), 13', ',')
['123', '[45, 67]', '(89,[10,11],12)', '13']
>>> split_list1 ('12, "34,56", 78', ',')
['12', '"34,56"', '78']
>>> dq='"'
>>> sq="'"
>>> bs='\\\\'
>>> len(bs)
1
>>> split_list1 ('12, "34,56", '+sq+'11,12'+sq+', 78', ',')
['12', '"34,56"', "'11,12'", '78']
>>> split_list1 ('12, "34,56'+bs+dq+',99", '+sq+'11,12'+sq+', 78', ',')
['12', '"34,56\\\\",99"', "'11,12'", '78']
>>> split_list1 ('12, "34,56'+bs+bs+dq+',99, '+sq+'11,12'+sq+', 78', ',')
['12', '"34,56\\\\\\\\"', '99', "'11,12'", '78']
Definition at line 3 of file split_list.py.
4 """Split the string L at the character DELIM.
5 But don't split within groups nested in ([{}]) or in strings.
7 >>> split_list1 ('12345', ',')
9 >>> split_list1 ('123, [45, 67], (89,[10,11],12), 13', ',')
10 ['123', '[45, 67]', '(89,[10,11],12)', '13']
11 >>> split_list1 ('12, "34,56", 78', ',')
12 ['12', '"34,56"', '78']
18 >>> split_list1 ('12, "34,56", '+sq+'11,12'+sq+', 78', ',')
19 ['12', '"34,56"', "'11,12'", '78']
20 >>> split_list1 ('12, "34,56'+bs+dq+',99", '+sq+'11,12'+sq+', 78', ',')
21 ['12', '"34,56\\\\",99"', "'11,12'", '78']
22 >>> split_list1 ('12, "34,56'+bs+bs+dq+',99, '+sq+'11,12'+sq+', 78', ',')
23 ['12', '"34,56\\\\\\\\"', '99', "'11,12'", '78']
33 if c == delim
and nest == 0:
43 while j < sz
and not (l[j] == c
and not esc):
52 while i < sz
and l[i] ==
' ':