[ create a new paste ] login | about

Link: http://codepad.org/2qWBifXW    [ raw code | output | fork ]

Python, pasted on Nov 19:
1
2
3
4
5
6
7
8
9
10
11
12
13
def split_list(seq, m='@'):
  r = []
  t = []
  for i in seq:
    if t and i.startswith(m):
      r.append(t)
      t = []
    t.append(i)
  if t:
    r.append(t)
  return r

print split_list(['foo', 'hoge', '@fuga', 'piyo', 'moe', '@hoe']) 


Output:
1
[['foo', 'hoge'], ['@fuga', 'piyo', 'moe'], ['@hoe']]


Create a new paste based on this one


Comments: