# Usage of eval()

**URL:** <https://forum.inductiveautomation.com/t/usage-of-eval/94435>\
**Category:** Ignition\
**Tags:** ignition81, scripting\
**Created:** [August 9, 2024, 5:34pm UTC](https://forum.inductiveautomation.com/t/usage-of-eval/94435 "2024-08-09T17:34:48Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jackson\_Lancaster](https://avatars.discourse-cdn.com/v4/letter/j/ebca7d/32.png) [@Jackson\_Lancaster](https://forum.inductiveautomation.com/u/Jackson_Lancaster)\
**Post date:** [August 9, 2024, 5:34pm UTC](https://forum.inductiveautomation.com/t/usage-of-eval/94435/1 "2024-08-09T17:34:48Z")

</div>

Does the Ignition scripting engine support eval()?

Here is an example of Python eval function. I get error in the script console when I execute this.

```python
cmd = '''
print (55)
'''
eval(cmd)

Traceback (most recent call last):
  File "<input>", line 6, in <module>
  File "<string>", line 2
    print (55)
    ^
SyntaxError: no viable alternative at input 'print'

```

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [August 9, 2024, 5:37pm UTC](https://forum.inductiveautomation.com/t/usage-of-eval/94435/2 "2024-08-09T17:37:49Z")

</div>

Yes, but, and I can't really understate this...

# Don't use eval.

The error in your snippet is because Ignition's scripting environment is Jython, which uses Python **2** syntax. So `print` is a _statement_, not a _function_.

But, seriously:

# Don't use eval.

Whatever thing you're trying to do, there's a better way to do it than `eval`. _Guaranteed_.

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [August 10, 2024, 11:46am UTC](https://forum.inductiveautomation.com/t/usage-of-eval/94435/3 "2024-08-10T11:46:20Z")

</div>

> [@paul-griffith](#):
>
> Don't use eval

Hmmm. I'm a bad boy. My spreadsheet import tool runs it with user-supplied content.

But I agree, in general.
