简体   繁体   中英

How do I check for type equality (is operator or x.GetType() == typeof(xType)) in IronPython?

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)
from System import *
if x.GetType() == Type.GetType(xType):

Say C is a static class, not fully qualified but imported into the iron python script x is an instance of C And ABC 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)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM