pattern search

Fabian Braennstroem f.braennstroem at gmx.de
Tue Mar 27 13:16:45 EDT 2007


Hi,

I wrote a small gtk file manager, which works pretty well. Until
now, I am able to select different file (treeview entries) just by
extension (done with 'endswith'). See the little part below:

                self.pathlist1=[ ]
                self.patternlist=[ ]
                while iter:
#                print iter
                    value = model.get_value(iter, 1)
#                if value is what I'm looking for:
                    if value.endswith("."+ pattern):
                        selection.select_iter(iter)
                        selection.select_path(n)
                        self.pathlist1.append(n)
                        self.patternlist.append(value)
                    iter = model.iter_next(iter)
#                print value
                    n=n+1

Now, I would like to improve it by searching for different 'real'
patterns just like using 'ls' in bash. E.g. the entry
'car*.pdf' should select all pdf files with a beginning 'car'.
Does anyone have an idea, how to do it?

Greetings!
Fabian




More information about the Python-list mailing list