Lists and split

magni2k magni2k at uni.de
Tue May 7 12:21:57 EDT 2002


Hi,

i've got a question about lists and how to split them.
This little function is not the whole script and my problem depends only on 
this short lines!
I want to split an external file into 3 single terms!
protocol, host, path for example
The file contains urls in form :
ftp://home.arcor.de/user/index/
http://www.python.org/index.html
...
So, what I want is to have a listing in form of:
['ftp', 'home.arcor.de', 'user/index']
['http', 'www.python.org', 'index.html'] 


def List(self):
       for line in ListFile(sys.argv[1]):
           serverlist = string.split(line, '://')
           print serverlist[1] 

Anybody perhaps an idea? The problem is how to split the 2nd time!! 

Thanks for everybody who reads and perhaps can help me ;-)
magni





More information about the Python-list mailing list