I want to convert C# statement
var f = userState as Fault
to ironpython statement
There are two parts to this.
If you are just trying to cast userState to a Fault then you don't need to do anything as Python is weakly typed.
If you are trying to determine if userState is of type Fault then try this
from System import *
if userState.GetType() == Type.GetType(Fault):
Without seeing the next line, it's hard to know what your intent is.
If you're downcasting (say from
Fault) - you don't have to! In IronPython members are looked up at runtime, so if
userState is already a
Fault you can treat it as one without any casting.
If you're trying to trigger an explicit/implicit conversion, use
If you're checking if
userState is a