If I understand what you're asking… you've got a list like this:
my_list_of_parm = ['I want this in',
yellow, 'yellow',
' and this is ',
green, 'green']
And you want to pass that to write_rich_string
as a bunch of separate arguments (along with one normal argument).
The way to do that is explained in the tutorial under Unpacking Argument Lists: Just put *
before my_list_of_parm
, and it will be unpacked into separate arguments:
worksheet.write_rich_string('A1', *my_list_of_parm)
In general, if you want to convert a list (or other iterable) into separate values or vice-versa, *
is the answer:
>>> def func(a, b, *args):
... print(args)
>>> func(1, 2, 3, 4, 5)
[3, 4, 5]
>>> a, b, *rest = [1, 2, 3, 4, 5]
>>> rest
[3, 4, 5]
>>> func(1, *rest)
[4, 5]
But for the exact rules on what you can and can't do, you'll need to read the docs.