Howcome some `system` functions take keyword args and some don't?

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

You mean :

system.gui.transform(component=event.source, [...])
vs
system.dataset.sort(event.source.data, [...])

You're asking why you can't explicitly say:

system.dataset.sort(dataset=event.source.data, [...])?

1 Like

Correct

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.

3 Likes

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.

3 Likes

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.

3 Likes