[Tutor] Compute data usage from log

2009-10-26 Thread bibi midi
Hi all! I have a file with data structure derived from wvdial log: Oct 14 11:03:45 cc02695 pppd[3092]: Sent 3489538 bytes, received 43317854 bytes. I want to get the 10th field of each line and get the sum for all lines (total my net data usage). In awk u can easily pop it using field variabl

Re: [Tutor] Compute data usage from log

2009-10-26 Thread Christian Witts
bibi midi wrote: Hi all! I have a file with data structure derived from wvdial log: Oct 14 11:03:45 cc02695 pppd[3092]: Sent 3489538 bytes, received 43317854 bytes. I want to get the 10th field of each line and get the sum for all lines (total my net data usage). In awk u can easily pop

Re: [Tutor] A question about the self and other stuff

2009-10-26 Thread Alan Gauld
"Khalid Al-Ghamdi" wrote class Robot: population = 0 def __init__(self, name): self.name=name print ('initializing {0}'.format(self.name)) Robot.population+=1 def __del__(self): '''I'm dying''' print ('{0} is being destroyed!'.format(self.name))

Re: [Tutor] Compute data usage from log

2009-10-26 Thread Luke Paireepinart
On Mon, Oct 26, 2009 at 3:20 AM, Christian Witts wrote: > fInput = open('/path/to/log.file', 'rb') > total_usage = 0 > for line in fInput: > total_usage += int(line.split(' ')[9].strip()) > print total_usage > It's actually bad to assign a variable to the file object in this case (flinput = ...

Re: [Tutor] how to use lxml and win32com?

2009-10-26 Thread elca
Alan Gauld wrote: > > > "elca" wrote > >> i want to use IE.navigate function with beautifulsoup or lxml.. >> if anyone know about this or sample. > > the parsers both effectively replace the browser so you > can't really use any functions of IE to modify soup or lxml. > > Why do you wan

Re: [Tutor] Reading information from a text file into a list of lists (WinXP/py2.6.2)

2009-10-26 Thread Kent Johnson
On Sun, Oct 25, 2009 at 6:53 PM, Katt wrote: > Hello all, > > Currently I am working on a program that reads text from a text file.  I > would like it to place the information int a list and inside the information > would have sublists of information. > > The text file looks like this: > > "Old Te

Re: [Tutor] Compute data usage from log

2009-10-26 Thread bibi midi
On Mon, Oct 26, 2009 at 2:12 PM, Luke Paireepinart wrote: > > > On Mon, Oct 26, 2009 at 3:20 AM, Christian Witts > wrote: > >> fInput = open('/path/to/log.file', 'rb') >> total_usage = 0 >> for line in fInput: >> total_usage += int(line.split(' ')[9].strip()) >> print total_usage >> > > It's ac

Re: [Tutor] how to use lxml and win32com?

2009-10-26 Thread Alan Gauld
"elca" wrote i want to use IE.navigate function with beautifulsoup or lxml.. if anyone know about this or sample. Why do you want to use navigate()? What are you trying to do? There is likely to be another way to do it from Python. so why i try to use PAMIE or IE http://elca.pastebin.com/

[Tutor] Function design

2009-10-26 Thread Eduardo Vieira
Hello, I need your help in designing a function. I have created this script to check out if certain column in some csv files has value "0": import csv def zerofound(csvfile, outputfile, lastcolumn ): """Finds columns with zero prices. Column have 0 index""" final = csv.writer(open(outputf

Re: [Tutor] Function design

2009-10-26 Thread Luke Paireepinart
On Mon, Oct 26, 2009 at 2:08 PM, Eduardo Vieira wrote: > Hello, I need your help in designing a function. I have created this > script to check out if certain column in some csv files has value "0": > > import csv > > def zerofound(csvfile, outputfile, lastcolumn ): >"""Finds columns with zero

[Tutor] HttpResponse error

2009-10-26 Thread Vincent Jones
SyntaxError at / ("'return' outside function", ('c:\\Users\\Vincent\\Documents\\django_bookmarks\\..\\django_bookmarks\\boo kmarks\\views.py', 15, None, 'return HttpResponse(output)\n')) As you can tell I am very new to this I am realizing that it is very important that indention and syntax

Re: [Tutor] HttpResponse error

2009-10-26 Thread Serdar Tumgoren
> Exception Type: SyntaxError at / > > Exception Value: ("'return' outside function", > ('c:\\Users\\Vincent\\Documents\\django_bookmarks\\..\\django_bookmarks\\bookmarks\\views.py', > 15, None, 'return HttpResponse(output)\n')) > The Error message indicates that you've diagnosed the problem corre

Re: [Tutor] how to use lxml and win32com?

2009-10-26 Thread elca
Alan Gauld wrote: > > > "elca" wrote > i want to use IE.navigate function with beautifulsoup or lxml.. if anyone know about this or sample. >>> Why do you want to use navigate()? What are you trying to do? >>> There is likely to be another way to do it from Python. > >> so why i

Re: [Tutor] HttpResponse error

2009-10-26 Thread Dave Angel
Vincent Jones wrote: SyntaxError at / ("'return' outside function", ('c:\\Users\\Vincent\\Documents\\django_bookmarks\\..\\django_bookmarks\\boo kmarks\\views.py', 15, None, 'return HttpResponse(output)\n')) from django.http import HttpResponse def main_page(request) : output = '''

Re: [Tutor] Function design

2009-10-26 Thread Dave Angel
Luke Paireepinart wrote: On Mon, Oct 26, 2009 at 2:08 PM, Eduardo Vieira wrote: Hello, I need your help in designing a function. I have created this script to check out if certain column in some csv files has value "0": import csv def zerofound(csvfile, outputfile, lastcolumn ): """Find

Re: [Tutor] Function design

2009-10-26 Thread Alan Gauld
"Eduardo Vieira" wrote def zerofound(csvfile, outputfile, lastcolumn ): """Finds columns with zero prices. Column have 0 index""" final = csv.writer(open(outputfile, 'wb'), dialect='excel') reader = csv.reader(open(csvfile, 'rb'), dialect='excel') for row in reader: if '0'