0

Why is (*) used in python before any var? like *mat

11th Oct 2018, 6:32 PM
Pranay Bhoir.
Pranay Bhoir. - avatar
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
11th Oct 2018, 7:00 PM
David Ashton
David Ashton - avatar
0
Thanks
11th Oct 2018, 6:47 PM
Pranay Bhoir.
Pranay Bhoir. - avatar