regexp spec

mario ruggier <[email protected]>
Newsgroups gmane.comp.web.quixote.user
Message-ID <[email protected]>
Would this be a good way to define a regexp (dulcinea) ?

mario

class regexp(SpecOperator):

     def __init__(self, pattern='^[-A-Za-z0-9_@.]*$'):
         import re
         self.re = re.compile(pattern)
         self.args =  (self.re,)

     def __call__(self, value):
         try:
             if self.re.match(value):
                 return True
             return False
         except TypeError:
             return False

     def __str__(self):
         return "string matching pattern '%s'" % (self.re.pattern)
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.