Top  | Previous | Next

About Python

While it is entirely possible to create a complete and powerful project in Ignition without writing a line of script, many designers will find that in order to complete projects with specific requirements, they need to learn at least a little Python. In our experience, most industrial projects involve lots of very complex and specific requirements.

 

The good news is that learning Python is easy and enjoyable. Python is one of the most beautiful programming languages we've ever encountered. It is very easy to read - even if you don't know it at all, you will probably be able to understand a basic Python script. It is frequently called it "executable pseudocode". We've included a short tutorial here which should help get you started. If you find yourself doing a lot of scripting, you may want to pick up a basic reference book about Python.

Scripting Help

Scripting is one of the topics in Ignition that users frequently need help with, because it is used to achieve some of the most complex requirements of a project. If you get stuck designing a script, or would like help getting started, don't hesitate to get some help. Our user forum at http://www.inductiveautomation.com/forum is by far the best place for scripting help.

 

When asking for scripting help - be precise and complete. If you're working through an error - include the text of the error, the circumstances, and the offending code. If you're stuck on something, it is helpful to describe the broader goals of what you're trying to accomplish - there is often an easy way and a hard way. Don't be shy to simply ask for some direction getting started.

eyeglasses Under the hood - Python in Java

The implementation of Python included in Ignition is Jython 2.5. While this is not the "latest" version of Python, it supports the vast majority of what people consider "python". The latest version of Python, version 3, is actually more of a branch, with many significant changes. The vast majority of sample code to be found was written against version 2.

 

One of the powerful things about using Jython is that your script has access to the entire Java standard library. In the Client, this will be Java 5 or above. When running under the Gateway, this will be Java 6 and above. See Accessing Java for more information.

 

Many scripting users are blown away by their script's speed. We can't take credit for this - the Jython engine hot-compiles your Jython code to Java bytecode, which means it runs natively in the JVM, which in turn can hot-compile it to machine code. It's fast.