Type of regular expression
Joakim Hove
hove at bccs.no
Fri Jul 2 07:12:09 EDT 2004
Peter Otten <__peter__ at web.de> writes:
> The easiest way to get the type of regular expressions:
>
>>>> import re
>>>> r = re.compile("")
>>>> RegexType = type(r)
>>>> del r
>
> The types has examples where it's done in exactly the same way.
> Now do the test:
>
>>>> isinstance(re.compile("abc"), RegexType)
> True
>>>> isinstance("abc", RegexType)
> False
That was elegant - thanks a lot.
Joakim
--
/--------------------------------------------------------------------\
/ Joakim Hove / hove at bccs.no / (55 5) 84076 | \
| Unifob AS, Avdeling for Beregningsvitenskap (BCCS) | Stabburveien 18 |
| CMU | 5231 Paradis |
\ Thormøhlensgt.55, 5020 Bergen. | 55 91 28 18 /
\--------------------------------------------------------------------/
More information about the Python-list
mailing list