I’m not sure what you mean by having less code in your tests? With this there is no code in the test just in the custom keyword.
If you mean you want to avoid including python files? there is another option and that is use the Evaluate function, but this will only be useful if you can resolve your custom variable with a single line of python, here is an example I gave where a single line of python calls to native python functions, but in my view that would mean having more code in your tests, I think the custom keyword is cleaner and more readable.
Beyond that you should refer to Extending Robot Framework in the user guide if you want to build a custom VariableResolver library, I’m not sure what you’ll need to do to make that work, i’m guessing a custom listener to catch variables in your format and a library that processes the variable and return the value, but this is a lot of coding to solve a problem that could just as easily be solved with a simple python keyword.
I don’t know of any other options, so I hope one of these helps you,