[Python-Dev] type categories -- an example
Mon, 19 Aug 2002 18:32:11 -0400
>>>>> "AK" == Andrew Koenig <firstname.lastname@example.org> writes:
Jeremy> I'd put this at the module level: compiled_re_type =
Jeremy> Then you can use isistance() to test:
Jeremy> isinstance(re.compile("spam+"), compiled_re_type)
AK> But is it guaranteed that re.compile will always yield an object
AK> of the same type?
Hard to say. I can read the code and see that the current
implementation will always return objects of the same type. In fact,
it's using type(sre_compile.compile("", 0)) internally to represent
That's not a guarantee. Perhaps Fredrik wants to reserve the right to
change this in the future. It's not unusual for Python modules to be
under-specified in this way.