# How to access 'system variable' directly in Python code?

**URL:** https://discourse.processing.org/t/how-to-access-system-variable-directly-in-python-code/35550
**Category:** Processing.py
**Created:** [March 4, 2022, 11:01am UTC](https://discourse.processing.org/t/how-to-access-system-variable-directly-in-python-code/35550 "2022-03-04T11:01:38Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![sweetart](https://avatars.discourse-cdn.com/v4/letter/s/e47c2d/32.png) [@sweetart](https://discourse.processing.org/u/sweetart)
#### Post date: [March 4, 2022, 11:01am UTC](https://discourse.processing.org/t/how-to-access-system-variable-directly-in-python-code/35550/1 "2022-03-04T11:01:38Z")

</div>

Dear All,

I’m using the processing-py 0.3.7 library directly in visual studio code. The because I want to combine the results with other code/libraries. The thing i’m stuck with is how do I access a ‘system variable’ such as frameCount?

For example when defined the app as:

`app = App(800,800)`

you can access it by:

`app.background(255)`

But how do you access frameCount? For example in the following case:

```auto
def draw(app):

    if (frameCount() % 10 == 0):

```

Thanks in advance for any help.

---

<div class="post-metadata">

### Author: ![villares](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/villares/32/3166_2.png) [@villares](https://discourse.processing.org/u/villares)
#### Post date: [March 4, 2022, 2:45pm UTC](https://discourse.processing.org/t/how-to-access-system-variable-directly-in-python-code/35550/2 "2022-03-04T14:45:32Z")

</div>

The command line feature that allows one to use Processing Python mode outside the Processing IDE is not currently maintained, unfortunately. I always had a hard time making it work. There was some discussion on using it with Atom: [How to run Processing Python Mode in Atom? - #3 by BeastCoder](https://discourse.processing.org/t/how-to-run-processing-python-mode-in-atom/16225/3) and maybe VS Code but I couldn’t find them right now.

I’m unfamiliar with the kind of instantiation you are doing. For simple sketches  
one should be able to just use the global name `frameCount`, I believe. 😕

Another idea, if you want to integrate with modern Python libraries, would be to use a completely external Python 3 environment using [py5](http://py5.ixora.io) (Python 3 + Java with JPype) or [p5py](https://github.com/p5py/p5) (Python 3, no Java) instead. 🙂

---

<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: [March 4, 2022, 2:50pm UTC](https://discourse.processing.org/t/how-to-access-system-variable-directly-in-python-code/35550/3 "2022-03-04T14:50:39Z")

</div>

> [@sweetart](#):
>
> But how do you access _frameCount_?

Python Mode in the PDE creates a global variable named _this_ which holds the PApplet reference for the whole sketch.

---

<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: [March 5, 2022, 12:11am UTC](https://discourse.processing.org/t/how-to-access-system-variable-directly-in-python-code/35550/4 "2022-03-05T00:11:09Z")

</div>

@villares’ py5 link is broken. @sweetart, you can use this link: [https://py5.ixora.io/](https://py5.ixora.io/)

If by “other code/libraries” you mean _other Python libraries and/or Processing libraries_, then you’ll want to opt for py5 over pyp5.

---

<div class="post-metadata">

### Author: ![villares](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/villares/32/3166_2.png) [@villares](https://discourse.processing.org/u/villares)
#### Post date: [March 5, 2022, 12:12am UTC](https://discourse.processing.org/t/how-to-access-system-variable-directly-in-python-code/35550/5 "2022-03-05T00:12:42Z")

</div>

thanks! I fixed the link now I think!

---

<div class="post-metadata">

### Author: ![sweetart](https://avatars.discourse-cdn.com/v4/letter/s/e47c2d/32.png) [@sweetart](https://discourse.processing.org/u/sweetart)
#### Post date: [March 7, 2022, 7:38pm UTC](https://discourse.processing.org/t/how-to-access-system-variable-directly-in-python-code/35550/6 "2022-03-07T19:38:51Z")

</div>

Dear All,

Thank you for your answers. I downloaded the py5 libary and I’m going to try to create the code with this.

Kind regards.
