On Thu, 03 Jan 2008 11:38:48 -0300, Bruno Ferreira wrote: > Hi, > > I wrote a very simple python program to generate a sorted list of lines > from a squid access log file. > > Here is a simplified version: > > ################################## > 1 logfile = open ("squid_access.log", "r") > 2 topsquid = [["0", "0", "0", "0", "0", "0", "0"]]
[snip] Others have already solved the immediate problem, but a much better design would be to avoid using a global variable in the first place. def add_sorted(alist, data): """Add figures from alist to collated data and return data.""" # do your processing here... return data topsquid=[["0", "0", "0", "0", "0", "0", "0"]] for line in logfile: linefields = logline.split() topsquid = add_sorted(linefields, topsquid) -- Steven -- http://mail.python.org/mailman/listinfo/python-list