# Using python to do a counter in dynamo

**URL:** <https://forum.dynamobim.com/t/using-python-to-do-a-counter-in-dynamo/80467>\
**Category:** Developers\
**Created:** [August 30, 2022, 5:26am UTC](https://forum.dynamobim.com/t/using-python-to-do-a-counter-in-dynamo/80467 "2022-08-30T05:26:24Z")\
**Posts on this page:** 1\
**Showing post:** 7

<div class="post-metadata">

**Author:** ![c.poupin](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/c.poupin/32/89152_2.png) [@c.poupin](https://forum.dynamobim.com/u/c.poupin)\
**Post date:** [August 30, 2022, 1:58pm UTC](https://forum.dynamobim.com/t/using-python-to-do-a-counter-in-dynamo/80467/7 "2022-08-30T13:58:46Z")

</div>

> [@yangshilun2012](#):
>
> I wrote a short script, it can not run as a counter, always show 1.

Hello  
because the node and the variables are re-initialized at each instance/launch  
some solutions:

- save the variable outside the script (txt file, pickle, …)
- use a node to get/set the variable (see [this example](https://forum.dynamobim.com/t/counter-of-runs-in-dynamo-script/74684/4))

---

_[View the full topic](https://forum.dynamobim.com/t/using-python-to-do-a-counter-in-dynamo/80467)._
