[Python-Dev] type categories -- an example
Andrew Koenig
ark@research.att.com
Tue, 20 Aug 2002 10:14:26 -0400 (EDT)
Casey> In general you wouldn't care whether is was a sre_foo or an sre_bar, just if
Casey> it acts like a compiled regular expression, and therefore supports that
Casey> interface. So, the real solution would be to have re assert that interface on
Casey> whatever the compiler returns so that you can check for it, something like:
Casey> if ISre.isImplementedBy(unknown_ob):
Casey> # It's a regex
Casey> Where ISre is the compiled regular expression interface object. If the
Casey> implementation varies the test would still work. Even if the interface
Casey> varied, the test would work (but it might break other stuff).
Exactly.