# \[RESOLVED\] Declaring a class function and using it inside the same class?

**URL:** <https://discourse.processing.org/t/resolved-declaring-a-class-function-and-using-it-inside-the-same-class/7626>\
**Category:** Processing.py\
**Created:** [January 18, 2019, 6:03pm UTC](https://discourse.processing.org/t/resolved-declaring-a-class-function-and-using-it-inside-the-same-class/7626 "2019-01-18T18:03:54Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sky](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/sky/32/3013_2.png) [@Sky](https://discourse.processing.org/u/Sky)\
**Post date:** [January 18, 2019, 6:03pm UTC](https://discourse.processing.org/t/resolved-declaring-a-class-function-and-using-it-inside-the-same-class/7626/1 "2019-01-18T18:03:54Z")

</div>

```auto
   def idle(self):
        if self.imgcount > len(self.idle) - 1 :
                    self.imgcount = 0 
        if self.face == 'RIGHT':
                image(self.idle[self.imgcount],self.vec.x,self.vec.y,self.w,self.h)  
        elif self.face == 'LEFT':
                pushMatrix()
                scale(-1,1)
                image(self.idle[self.imgcount],-self.vec.x - self.w,self.vec.y,self.w,self.h)
                popMatrix()          
        self.imgcount += 1

    def show(self):        
        if not keyPressed:
            idle()

```

How to make this code work? It says idle() doesnt exist  
(and this what I expected),but idk how to make it work  
[Full code here](https://drive.google.com/open?id=1ThJh5SCujjM7nqqk-m0XZVa8WkHX8lpf)

---

<div class="post-metadata">

**Author:** ![solub](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/solub/32/333_2.png) [@solub](https://discourse.processing.org/u/solub)\
**Post date:** [January 19, 2019, 10:50am UTC](https://discourse.processing.org/t/resolved-declaring-a-class-function-and-using-it-inside-the-same-class/7626/2 "2019-01-19T10:50:29Z")

</div>

Hi,

I can’t test your code at the moment but the problem might be because of the missing “self.” before idle() on the last line.

---

<div class="post-metadata">

**Author:** ![Sky](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/sky/32/3013_2.png) [@Sky](https://discourse.processing.org/u/Sky)\
**Post date:** [January 19, 2019, 2:04pm UTC](https://discourse.processing.org/t/resolved-declaring-a-class-function-and-using-it-inside-the-same-class/7626/3 "2019-01-19T14:04:15Z")

</div>

It says:

> processing.app.SketchException: TypeError: ‘list’ object is not callable

If you want you can download the full code [here](https://drive.google.com/open?id=1ThJh5SCujjM7nqqk-m0XZVa8WkHX8lpf) if you are interested

---

<div class="post-metadata">

**Author:** ![Sky](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/sky/32/3013_2.png) [@Sky](https://discourse.processing.org/u/Sky)\
**Post date:** [January 20, 2019, 5:07pm UTC](https://discourse.processing.org/t/resolved-declaring-a-class-function-and-using-it-inside-the-same-class/7626/4 "2019-01-20T17:07:21Z")

</div>

Ok, no problem, I did some simple code to try what you said,it worked, and I realized my error comes from somewhere else 😌😌🤪
