Why not 3.__class__ ?

James_Althoff at i2.com James_Althoff at i2.com
Fri Oct 12 14:24:08 EDT 2001


Walter Dörwald wrote:
>The only type still missing is module (at least for type checks, I don't
>  know what the factory function module should do, and how deriving from
>module would be useful).

Good point.

For now, it seems like three choices are available (for the isinstance
check):
1) the "butt ugly" mechanism,
2) the "type-method spelled backwards" mechanism,
3) the "import types / heavy artillery" mechanism,
(<wink>s throughout)

Python 2.2a1 (#21, Jul 18 2001, 04:25:46) [MSC 32 bit (Intel)] on win32
Type "copyright", "credits" or "license" for more information.
>>>
>>> import thread as t
>>>
>>> isinstance(t, __builtins__.__class__)
1
>>>
>>> isinstance(t, type(__builtins__))
1
>>>
>>> import types
>>> isinstance(t, types.ModuleType)
1
>>>

Don't know if there are any plans/thoughts regarding the addition of a
"module" or "mod" equivalent of "int" (etc.) someday.

Jim





More information about the Python-list mailing list