0
Why is (*) used in python before any var? like *mat
2 ответов
+ 4
The asterisk is being used as the 'unpack' (or 'splat') operator. Here are a couple of links:
https://codeyarns.com/2012/04/26/unpack-operator-in-JUMP_LINK__&&__python__&&__JUMP_LINK/
https://medium.com/understand-the-python/understanding-the-asterisk-of-python-8b9daaa4a558
It's also handy for printing iterables, e.g. printing a list without the brackets and commas:
print([c for c in "dog"]) # output: ['d', 'o', 'g']
print(*[c for c in "dog"]) # output: d o g
0
Thanks