I would start with something like this: somestring = '/foo/bar/beer/sex/cigarettes/drugs/alcohol/' somelist = somestring.split('/') print somelist This is close to what you seem to want. Good luck. *gina*
-----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Sent: Friday, February 25, 2005 8:36 AM To: python-list@python.org Subject: split a directory string into a list QUESTION: How do I split a directory string into a list in Python, eg. '/foo/bar/beer/sex/cigarettes/drugs/alcohol/' becomes ['foo','bar','beer','sex','cigarettes','drugs','alcohol'] I was looking at the os.path.split command, but it only seems to separate the filename from the path (or am I just using it wrong?). I don't want to do it manually if I can help it, as there will have to be exceptions for the cases where there is (not) a trailing (leading) slash, or escape sequences involving /. Is there a built in command for this? -- http://mail.python.org/mailman/listinfo/python-list