Question in the title. E.g. system.dataset.sort doesn't take keyword args, but most do. Just wondering the reason most do but some don't? I like providing keyword args since it both:
makes it easier to read later on, especially if you're using a function you don't normally use
increases chances of backwards compatibility in case function arg definitions change (e.g. new args are added into existing arg indices) - this one should probably very rarely happen, but it's a possibility
Pure chance on whomever originally implemented the function, until IA made it an internal best practice to support them. Most of the newer stuff supports them.
Yeah. On our side, implementing with keyword args takes slightly more effort and means slightly more complicated unit testing. It's definitely my preference for all first party functions, though.
I only use them when there's a mix of required and optional parameters, and even then sparingly.
They're a bit of a footgun in some cases, and can lead to mistakes and confusion like this if you don't name every parameter in your calls and instead fall back to the implicit ordering.
com.inductiveautomation.ignition.common.script.JythonExecException
Traceback (most recent call last):
File "<function:runAction>", line 6, in runAction
File "<module:screen.tools>", line 1203, in getTagAddDataSetHeadersValuesToTag
TypeError: sort(): takes no keyword arguments
caused by org.python.core.PyException
Traceback (most recent call last):
File "<function:runAction>", line 6, in runAction
File "<module:screen.tools>", line 1203, in getTagAddDataSetHeadersValuesToTag
TypeError: sort(): takes no keyword arguments
Ignition v8.1.36 (b2024010211)
Java: Azul Systems, Inc. 17.0.8
You can use it. You just cannot use a keyword to supply it. If you look carefully at the docs, you will see ascending and naturalOrderingtogether in a single set of brackets. That tells me they are a pair, supply neither or both, but not just one.
When keyword arguments are supported, the docs say so.
Ohhh ok, I did not realize ignition made us do that. I was looking at it like python functions where we do not have to call them all was my mistake. That makes sense hank you!