Sorry, I assumed you had already read in your file and had access to each line. Just to be explicit, Casey's code would be placed in an External Method. More interesting, though, is how you expect to get the file. Will the filename be contained in a form that gets submitted to you, will you compute the filename, will it be hardcoded, will it be a "file" contained in the Zope database, or a regular file in the file system? The answers to questions like these will affect how you proceed. Cheers, Tom P [Casey Duncan]
"Thomas B. Passin" wrote:
Do a split on the ':'. It will give you a list containing the three
parts.
[Marcus Schopen]
what's the best way to read a flat file like this line by line and split each line to three variables?
1:menuname:url 1.1:submenuname:url 1.2:submenuname:url 2:nenuname:url 2.1:sub ...
import string
def readconfig(path): f = open(path) vars = [] for line in f.readlines(): vars.append(string.split(line,':')) f.close() return vars