python-like style

Giorgi Lekishvili gleki at
Wed Aug 21 17:01:07 CEST 2002

Hi all!

Description of my task:
Given a file. Given a list of keywords.
test whether a keyword is in the line and return the NEXT line. More
precisely, the list of all such lines.

Of course, I can do it ina n OO manner.

Anyway, I would like to do it in a functional manner.
Here comes, what I was trying to do.
>>>f=open(fn, 'r')
>>>def getit(it, kw):
...     if string.find(it, kw)>0:
...         return
...     else:
...         return 0
>>>rz=filter(None, map(apply(getit, s, kw), i))

No, the traceback:
File "D:\Python22\wxPython\tools\boa\ExternalLib\",
line 65, in push
    exec code in self.locals
  File "<console>", line 1, in ?
exceptions.NameError : name 's' is not defined

Thanks in advance.

PS. I am using Py 2.2.x, Boa.

More information about the Python-list mailing list