# Push and pop not working in p5py?

**URL:** <https://discourse.processing.org/t/push-and-pop-not-working-in-p5py/21653>\
**Category:** p5py\
**Created:** [June 7, 2020, 12:46pm UTC](https://discourse.processing.org/t/push-and-pop-not-working-in-p5py/21653 "2020-06-07T12:46:24Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![renec112](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/renec112/32/9168_2.png) [@renec112](https://discourse.processing.org/u/renec112)\
**Post date:** [June 7, 2020, 12:46pm UTC](https://discourse.processing.org/t/push-and-pop-not-working-in-p5py/21653/1 "2020-06-07T12:46:24Z")

</div>

I’m using the [python package p5python package p5](https://github.com/p5py/p5)

I’m following some tutorials written in javascript, but it seems like push and pop is not the same in the python package.

I’m using the push\_matrix() and the pop\_matrix() function.  
As far as I understand this code shouldn’t do anything:

push()  
translate(x,y)  
pop()

Right? because there is nothing inside the push pop function.

But In this Python example:

```auto
translate(100,100)
pop_matrix()
circle((500,500),50)

```

The circle has moved to position 600,600. I thought it should be at 500,500.

Would love your input. Full code:

```auto
from p5 import *

def setup():
    size(1000, 1000)

def draw():
    background(255)
    fill(0)
    push_matrix()
    translate(100,100)
    pop_matrix()
    circle((500,500),50)

run()

```

---

<div class="post-metadata">

**Author:** ![tabreturn](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/tabreturn/32/3697_2.png) [@tabreturn](https://discourse.processing.org/u/tabreturn)\
**Post date:** [June 7, 2020, 8:33pm UTC](https://discourse.processing.org/t/push-and-pop-not-working-in-p5py/21653/3 "2020-06-07T20:33:29Z")

</div>

According to the [documentation](https://p5.readthedocs.io/en/latest/guides/for-processing-users.html?highlight=push_matrix()#shapes-etc), this:

```auto
pushMatrix()
translate(width/2, height/2)
point(0, 0)
popMatrix()

```

becomes:

```auto
with push_matrix():
    translate(width/2, height/2)
    point(0, 0)

```

So in your case, you want something like this:

```auto
...

def draw():
    background(255)
    fill(0)

    with push_matrix():
        translate(100, 100)
        circle((500, 500), 50) # translated
    
    no_fill()
    circle((500, 500), 50) # centered

...

```

---

<div class="post-metadata">

**Author:** ![renec112](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/renec112/32/9168_2.png) [@renec112](https://discourse.processing.org/u/renec112)\
**Post date:** [June 13, 2020, 8:14pm UTC](https://discourse.processing.org/t/push-and-pop-not-working-in-p5py/21653/4 "2020-06-13T20:14:30Z")

</div>

thank you very much for the solution @tabreturn 🙂
