efficient text file search -solution

2006-09-11 Thread noro
OK, am not sure why, but fList=file('somefile').read() if fList.find('string') != -1: print 'FOUND' works much much faster. it is strange since i thought 'for line in file('somefile')' is optemized and read pages to the memory, i guess not..

Re: efficient text file search.

2006-09-11 Thread noro
inary search algorithm for text files out there or do i need to write one? Steve Holden wrote: > noro wrote: > > Bill Scherer wrote: > > > >>noro wrote: > >> > >> > >>>Is there a more efficient method to find a string in a text file then: > >

Re: efficient text file search.

2006-09-11 Thread noro
can you add some more info, or point me to a link, i havn't found anything about binary search in mmap() in python documents. the files are very big... thanks amit Bill Scherer wrote: > noro wrote: > > >Is there a more efficient method to find a string in a text file th

Re: efficient text file search.

2006-09-11 Thread noro
:) via python... Luuk wrote: > "noro" <[EMAIL PROTECTED]> schreef in bericht > news:[EMAIL PROTECTED] > > Is there a more efficient method to find a string in a text file then: > > > > f=file('somefile') > > for line in f: > >if &

efficient text file search.

2006-09-11 Thread noro
Is there a more efficient method to find a string in a text file then: f=file('somefile') for line in f: if 'string' in line: print 'FOUND' ? BTW: does "for line in f: " read a block of line to te memory or is it simply calls f.readline() many times? thanks amit -- http://mail.py

data structure

2006-09-03 Thread noro
Hello again. I have a task i need to do and i can't seem to find an elegent solution. i need to make a tree like data structure (not necessry a binary tree). i would like each node to access his sons in a dicionary kind of why, for example: if ROOT node has the name 'A' and 'AA', 'AB' are his s

Re: dictionary with object's method as thier items

2006-08-30 Thread noro
is code style? it is not very OOP, but i cant see how one can do it other wise, and be able to control the function printed out with something as easy as dictionary.. Georg Brandl wrote: > noro wrote: > > Is it possible to do the following: > > > > for a certain class: > >

dictionary with object's method as thier items

2006-08-30 Thread noro
Is it possible to do the following: for a certain class: class C: def func1(self): pass def func2(self): pass def func4(self): pass obj=C() by some way create a dictionary that look somthing like t

Re: unit test for a printing method

2006-08-29 Thread noro
Fredrik Lundh wrote: > Scott David Daniels wrote: > > > For silly module myprog.py: > > def A(s): > > print '---'+s+'---' > > in test_myprog.py: > > import unittest > > from cStringIO import StringIO # or from StringIO ... > > why are you trying to reinvent doctest ? > >

unit test for a printing method

2006-08-28 Thread noro
What is the proper way to test (using unit test) a method that print information? for example: def A(s): print '---'+s+'---' and i want to check that A("bla") really print out "---bla---" thanks amit -- http://mail.python.org/mailman/listinfo/python-list

Re: creating multiply arguments for a method.

2006-08-28 Thread noro
John Roth wrote: > noro wrote: > > Hi all, > > > > I use a method that accept multiply arguments ("plot(*args)"). > > so plot([1,2,3,4]) is accepted and plot([1,2,3,4],[5,6,7,8]) is also > > accepted. > > > > the problem is that i know th

creating multiply arguments for a method.

2006-08-27 Thread noro
Hi all, I use a method that accept multiply arguments ("plot(*args)"). so plot([1,2,3,4]) is accepted and plot([1,2,3,4],[5,6,7,8]) is also accepted. the problem is that i know the number of arguments only at runtime. Let say that during runtime i need to pass 4 arguments, each is a list, creatin

Re: local moduile acess from cgi-bin

2006-07-26 Thread noro
thanks bruno Bruno Desthuilliers wrote: > noro wrote: > > hello all. > > > > I do some coding in python but this is my first attampt to write > > somthing for hte web. > > > > I need to write a cgi-bin script for a web-server, and i've got the > &g

local moduile acess from cgi-bin

2006-07-25 Thread noro
hello all. I do some coding in python but this is my first attampt to write somthing for hte web. I need to write a cgi-bin script for a web-server, and i've got the access for it from our "SYSTEM". the problem is that this script uses some modules (pg, pyLab) that i've installed localy in my hom