List of libraries used in import in scripts

How can I find out what library/namespace I need to import in order for a function to work in a script?

For example, I am trying to use ‘trim’ on a variable in a project script and it gives me an error ‘trim’ is not defined.

I need to know how to find the proper namespace given a function.

I think you are confusing expression language and python.
The equivalent function in python for trim is strip.

s = " this is a string " print s.strip()

Yes, I was confused between python and expression language in the example I gave. Thanks for the information. That said, the original question still applies.

How can I find out what library/namespace I need to import in order for a function to work in a script?
I need to know how to find the proper namespace given a function. Is there a list of import libraries that I can reference that shows the functions included in the import.

Sorry such a long delay, I forgot I had asked this question and will monitor much more closely this time.

Generally, you want to study the jython documentation. There’s a few inaccuracies, as it was copied from python v2.7, and some of that doesn’t apply. As for functions supplied by IA, you generally don’t need to import at all – just spell it out. These are all documented here. Add-on modules from third parties can also supply functions in system.* – they won’t need imports either, but you’ll need the module documentation.
One of the big advantages of Ignition is its Java base, which is accessible from jython. Those you need to import, though. See the Java base here and Ignition’s object docs here.

Have fun!

Google searches are also great. I’m a ‘learn by example’ kind of guy. My Google searches are more task oriented (example: ‘python dictionary from csv’). Once I see an example or two, I can then modify to my own needs.

If I get really stuck, I usually ask Phil. :slight_smile:

1 Like

Thank you guys, I will reference those links you provided.