# Isinstance() not working between classobj and instance

**URL:** <https://forum.inductiveautomation.com/t/isinstance-not-working-between-classobj-and-instance/97673>\
**Category:** Ignition\
**Tags:** ignition81\
**Created:** [October 23, 2024, 3:12pm UTC](https://forum.inductiveautomation.com/t/isinstance-not-working-between-classobj-and-instance/97673 "2024-10-23T15:12:08Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![danielps1818](https://avatars.discourse-cdn.com/v4/letter/d/ecae2f/32.png) [@danielps1818](https://forum.inductiveautomation.com/u/danielps1818)\
**Post date:** [October 23, 2024, 3:12pm UTC](https://forum.inductiveautomation.com/t/isinstance-not-working-between-classobj-and-instance/97673/1 "2024-10-23T15:12:08Z")

</div>

Hi!  
Here _ **path** _ correspond to the correct path of the function, not simply _path_.

```python
class C1:
    def __init__ (self, param1)
    self.param1 = param1

```

```python
def fun1():
    c = path.C1("example")

    return path.fun2(c)

```

```python
def fun2(obj):
    print type(obj)
    print type(path.C1)
    return isinstance(obj, path.C1)

```

For some reason `fun1()` returns `False`.

```python
<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

```python
<type 'classObj'>
<type 'classObj'>
False

```

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [October 23, 2024, 3:15pm UTC](https://forum.inductiveautomation.com/t/isinstance-not-working-between-classobj-and-instance/97673/2 "2024-10-23T15:15:34Z")

</div>

> [@danielps1818](#):
>
> `class C1:`

Try

```python
class C1(object):

```

And go read up on legacy versus modern classes in python 2.

---

<div class="post-metadata">

**Author:** ![danielps1818](https://avatars.discourse-cdn.com/v4/letter/d/ecae2f/32.png) [@danielps1818](https://forum.inductiveautomation.com/u/danielps1818)\
**Post date:** [October 23, 2024, 3:26pm UTC](https://forum.inductiveautomation.com/t/isinstance-not-working-between-classobj-and-instance/97673/3 "2024-10-23T15:26:57Z")

</div>

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:**

```python
class C1(object):
    def __init__ (self, param1)
    self.param1 = param1

```

```python
<type 'path.C1'> # not totally sure
<type 'type'>
True

```

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [October 23, 2024, 4:55pm UTC](https://forum.inductiveautomation.com/t/isinstance-not-working-between-classobj-and-instance/97673/4 "2024-10-23T16:55:39Z")

</div>

> [@danielps1818](#):
>
> we can't use imports

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:

> [@Project Library Script Initialization Races](https://forum.inductiveautomation.com/t/project-library-script-initialization-races/98636):
>
> Are you annoyed by pseudo-random breakage in Ignition project library scripting? Odd top-level constants being garbled, or operations in the top level that have side effects running twice? Or more? Not happening much, but always around project edits, and sometimes even on gateway restart? Yeah, me too. frowning_face Poking around under the hood back in the spring, for a module development task, I ran across some problematic IA bytecode and pinged some people. But it went nowhere, as I co…
