Is there a better way to do this, or for light use is this just fine?

As part of my color Multi-tool project, I do this kind of thing. I’m guessing that there are better ways, but I’m not sure it’s worth the trouble to try.

Any opinions?

This is a custom jinja template, and this is the output. However because it exports as a string I thought the format would be OK, didn’t really need to make it a list here. I am leaving instructions for the user to make this a list on the user end.

{%- set R = (range(255)|random) | int(0) -%}
{%- set G = (range(255)|random) | int(0) -%}
{%- set B = (range(255)|random) | int(0) -%}
{{- R -}},{{- G -}},{{- B -}}

range(255) is 0 to 254
range(256) is 0 to 255

Not sure if this is what you want but it produces a list containing three random integers ranging from 0 to 255.

{{ [range(256),range(256),range(256)]|map('random')|list }}

This version reports the result as a string.

{{ [range(256),range(256),range(256)]|map('random')|join(',') }}

Didn’t realize that. Makes sense, though, just a swing and a miss on my part.
Well that’s going to need changing in a few places. Thanks.

If you must have the RGB values in three separate variables, you can do this:

{% set (R,G,B) = [range(256),range(256),range(256)]|map('random')|list %}
{{ R }},{{ G }},{{ B }}