Basically I want to do this:
obj = 'str' type ( obj ) == string
type ( obj ) == type ( string )
and it didn't work.
Also, what about the other types? For example, I couldn't replicate
In your case,
isinstance("this is a string", str) will return
You may also want to read this: http://www.canonical.org/~kragen/isinstance/
if isinstance(obj, MyClass): do_foo(obj)
but, keep in mind: if it looks like a duck, and if it sounds like a duck, it is a duck.
EDIT: For the None type, you can simply do:
if obj is None: obj = MyClass()