# I have trouble with to get a simple class to work

**URL:** <https://discourse.processing.org/t/i-have-trouble-with-to-get-a-simple-class-to-work/17079>\
**Category:** Processing.py\
**Created:** [January 14, 2020, 9:39am UTC](https://discourse.processing.org/t/i-have-trouble-with-to-get-a-simple-class-to-work/17079 "2020-01-14T09:39:46Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![EvilDuck](https://avatars.discourse-cdn.com/v4/letter/e/f04885/32.png) [@EvilDuck](https://discourse.processing.org/u/EvilDuck)\
**Post date:** [January 14, 2020, 9:39am UTC](https://discourse.processing.org/t/i-have-trouble-with-to-get-a-simple-class-to-work/17079/1 "2020-01-14T09:39:46Z")

</div>

I want to learn Python, but I simply can’t get this to work. its really strange …  
I have two small code snippets posted here, when they reside in the same tab it works!. But if I put the class into its own tab I get a NameError(?). How can I get this to work properly?

In the main tab I have;

```auto
p1 = MyClass()
print(p1.x)

```

in the second tab I have;

```auto
class MyClass(object):
x = 5

```

---

<div class="post-metadata">

**Author:** ![GoToLoop](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/gotoloop/32/86_2.png) [@GoToLoop](https://discourse.processing.org/u/GoToLoop)\
**Post date:** [January 14, 2020, 10:01am UTC](https://discourse.processing.org/t/i-have-trouble-with-to-get-a-simple-class-to-work/17079/2 "2020-01-14T10:01:32Z")

</div>

> [@EvilDuck](#):
>
> How can I get get this to work properly?

We need `from "module_name" import "stuff"` in order to use stuff from other “.py” tab files: 🐍

> <https://gist.github.com/GoToLoop/893dc18856a7842b76a92d8aea837da1>

---

<div class="post-metadata">

**Author:** ![EvilDuck](https://avatars.discourse-cdn.com/v4/letter/e/f04885/32.png) [@EvilDuck](https://discourse.processing.org/u/EvilDuck)\
**Post date:** [January 14, 2020, 10:13am UTC](https://discourse.processing.org/t/i-have-trouble-with-to-get-a-simple-class-to-work/17079/3 "2020-01-14T10:13:47Z")

</div>

I did this;

# main tab

```auto
from Core import Core
core = Core()

def setup():
    size(1024, 1024)
    background(255,255,255)  
    

def draw():
        
    core.testStuff()
    noLoop()

```

# other tab

```auto
class Core():
    
    x_ = 7 
    
    def __init__ (self):
        self.field = [0] * 4096
        self.arrayStuff = [4, 8, 9]
        
    def testStuff( self ): 
        #println( "TEST! " + str( arrayStuff[0] ) )
        println( self.arrayStuff[0] )
        println( self.field[10] )

```

now it works perfectly!  
Many thx!
