# Imported class from another tab doesn't work

**URL:** <https://discourse.processing.org/t/imported-class-from-another-tab-doesnt-work/22135>\
**Category:** Processing.py\
**Created:** [June 24, 2020, 7:41pm UTC](https://discourse.processing.org/t/imported-class-from-another-tab-doesnt-work/22135 "2020-06-24T19:41:58Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Tahsin](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/tahsin/32/9900_2.png) [@Tahsin](https://discourse.processing.org/u/Tahsin)\
**Post date:** [June 24, 2020, 7:41pm UTC](https://discourse.processing.org/t/imported-class-from-another-tab-doesnt-work/22135/1 "2020-06-24T19:41:58Z")

</div>

Hey! So I’ve been trying to make a voronoi animation in processing.py and For some reason, I can’t call my voronoi class from the other tab.  
I’m getting the error : NameError: global name ‘v’ is not defined  
I can’t figure it out. please help!!!

**Voronoi.pyde**

````auto
from voronoi_class import *
w, h = 640, 480
global v
def setup():
    size(w, h)
    background(255)
    noStroke()
    colorMode(HSB, 360,100,100)
    v = voronoi(100, w, h)
    println(v.r)
    
def draw():
    if v.r >= 0:
        v.update()
    v.show()
    ```

**voronoi_class.py**

````

class voronoi:  
def **init** (self, number, w, h):  
self.points = []  
self.colors = []  
self.r = 1000  
self.n = number  
for i in range(self.n):  
self.points.append(PVector(random(1)\*w, random(1)\*h))  
self.colors.append((random(0,360), random(60,80), random(85,90)))  
def show(self):  
for c, p in enumerate(self.points):  
fill(self.colors[c][0], self.colors[c][1], self.colors[c][2])  
ellipse(p.x,p.y, self.r,self.r)  
def update(self):  
self.r-=1

```auto

```

---

<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:** [June 24, 2020, 8:09pm UTC](https://discourse.processing.org/t/imported-class-from-another-tab-doesnt-work/22135/2 "2020-06-24T20:09:02Z")

</div>

> [@Tahsin](#):
>
> I’m getting the error: NameError: global name ‘v’ is not defined

I believe you’ve got instead NameError: global name ‘voronoi’ is not defined, right?

> [@Tahsin](#):
>
> `from voronoi_class import *`

Should be instead: `from voronoi_class import voronoi`

> [@Tahsin](#):
>
> ```auto
> global v
> 
> def setup():
> 
> ```

Keyword `global` should go inside a function instead:

> **[Globals \\ Language (API)](https://py.processing.org/reference/globals.html)**
>
> Python Mode for Processing extends the Processing Development Environment with the Python programming language.

```auto
def setup():

    # ...

    global v
    v = voronoi(100, w, h)
    println(v.r)

```

> [@Tahsin](#):
>
> `class voronoi:`

It’s customary for class names to be “CamelCase” instead: `class Voronoi:`
