Re: problem with global var

2008-01-04 Thread Bruno Ferreira
Hello all, Amazing :) The program is working properly now, the code is much better and I learned a bit more Python. Thank you all, guys. Bruno. 2008/1/4, Peter Otten <[EMAIL PROTECTED]>: > Bruno Ferreira wrote: > > > I wrote a very simple python program to generate a sorted list of > > lines

Re: problem with global var

2008-01-04 Thread Peter Otten
Bruno Ferreira wrote: > I wrote a very simple python program to generate a sorted list of > lines from a squid access log file. Now that your immediate problem is solved it's time to look at the heapq module. It solves the problem of finding the N largest items in a list much more efficiently. I

Re: problem with global var

2008-01-03 Thread Steven D'Aprano
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

Re: problem with global var

2008-01-03 Thread Fredrik Lundh
Bruno Ferreira wrote: > When I execute the program _without_ the lines 10 and 11: > > 10 if len(topsquid) > 50: > 11 topsquid = topsquid[0:50] > > it runs perfectly. > > But if I execute the program _with_ those lines, this exception is thrown: > > [EMAIL PROTECTED]:~$ python topsq

Re: problem with global var

2008-01-03 Thread Diez B. Roggisch
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

Re: problem with global var

2008-01-03 Thread wes
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"

Re: problem with global var

2008-01-03 Thread Matt Nordhoff
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"

problem with global var

2008-01-03 Thread Bruno Ferreira
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"]] 3 4 def add_sorted (list): 5