Classes in Python

Wiebke Pätzold wiebke.paetzold at mplusr.de
Mon Aug 4 07:13:18 EDT 2003


On Mon, 04 Aug 2003 12:30:11 +0200, Wiebke Pätzold
<wiebke.paetzold at mplusr.de> wrote:

>Hi all!
>
>Could somebody help me with a task?
>
>import sys
>import Mk4py
>import re
>
>db = Mk4py.storage("c:\\datafile.mk",1)
>vw = db.view("people")
>
>class PatternFilter:
>    def _init_(self, pattern):
>        self.pattern = re.compile(pattern)
>
>    def _call_(self, row):
>        try:
>            nachname = row.Nachname
>        except AttributeError:
>            return 0
>        return self.pattern.search(nachname)is not None
>
>vf = vw.filter(PatternFilter("Ge.*"))
>
>for r in vf:
>    print  vw[r.index].Nachname
>    
>
>
>I wrote this program, but it returns nothing. I can't find the error.
>Can somebody help me? 
>Can somebody tell me why the part:   "class PatternFilter:"  doesn't
>return the expressions it should return?

I create a database that contains a table. 'Nachname' and
'Kongressbereich' are special fieldnames. This program can search for
a special letter. In my example it is 'G'. and the search takes place
in 'Nachname'.
Mow I want to use regular expression. So that I can limit my search.
For example: I can search for Ge and it is not relevant wich letters
follow
>
>Wiebke





More information about the Python-list mailing list