tags:

views:

333

answers:

2

Duplicate: What’s the canonical way to check for type in python?

How do I check for type equality in IronPython?

I need the equivalent of the following C# code in IronPython:

if (x.GetType() == typeof(xType))

or

if (x is xType)
+1  A: 
from System import *
if x.GetType() == Type.GetType(xType):
Josh Kodroff
A: 

Say C is a static class, not fully qualified but imported into the iron python script x is an instance of C And A.B.C is the fully qualified name

Why don't these work?

x.GetType() == Type.GetType("A.B.C")

OR

x is Type.GetType("A.B.C")

OR

x is C

OR

x.GetType() == Type.GetType(C)
I ended up doing this:x.GetType().Name == "C"