Hi!
Here path correspond to the correct path of the function, not simply path.
class C1:
def __init__(self, param1)
self.param1 = param1
def fun1():
c = path.C1("example")
return path.fun2(c)
def fun2(obj):
print type(obj)
print type(path.C1)
return isinstance(obj, path.C1)
For some reason fun1()
returns False
.
<type 'instance'>
<type 'classObj'>
False
How can I check a that an object is that specific object?
I want to check that obj
corresponds to path.C1
.
Hope it's clear the problem.
Thanks in advance!
Edit:
Using obj.__class__
returns
<type 'classObj'>
<type 'classObj'>
False
Try
class C1(object):
And go read up on legacy versus modern classes in python 2.
2 Likes
In my team we are always really impressed of how much information you know @pturmel .
Thanks a lot, that actually worked!
However, as note, we can't use imports we have to write the complete path so it doesn't returns a False.
Solution:
class C1(object):
def __init__(self, param1)
self.param1 = param1
<type 'path.C1'> # not totally sure
<type 'type'>
True
You can never safely use imports with Ignition project library scripts. Ignition doesn't use jython's import machinery.
Edit: This long-standing script library bug might be (part of) the reason for the no-import best practice:
1 Like