classes (table)

Christopher Boomer (don't dash!) c-b-o-o-m-e-r at tiscali.co.uk
Wed Aug 6 09:16:41 EDT 2003


>     def __call__(self, row):
>         try:
>             nachname = row.Nachname
>         except AttributeError:
>             return 0
>         return self.pattern.search(nachname)is not None

You should probably start by rewriting your basic function as

def search_call (self, row, column):
    if not hasattr(row, column):
        return 0 # No such column
    nachname=getattr(row, column)
    return self.pattern.search(nachname) is not None

Now you can choose the column at will within the program.
(nachname is now a poor choice of variable name)

To restrict access to columns, restrict this function and provide as a
public function the following:

def __call__ (self, row):
    return search_call(row, 'Nachname')

Hope this helps.

MfG
Christopher Boomer.






More information about the Python-list mailing list