On Fri, Jun 5, 2009 at 7:18 AM, Norman Khine<[email protected]> wrote: > Hello, > What is the way to group each value so that I get a list, from a string like: > > dir = '/expert/forum/expert/expert' > list = ['/expert', '/forum', '/expert', '/expert']
Here is one way using re.split(): In [28]: import re In [29]: [ x for x in re.split(r'(/[^/]+)', dir) if x ] Out[29]: ['/expert', '/forum', '/expert', '/expert'] Kent _______________________________________________ Tutor maillist - [email protected] http://mail.python.org/mailman/listinfo/tutor
