I don’t know if this counts as unpacking trick but something I’ve learned recently is that if you have an iterable, say a list, and you want to pass its contents to a function individually, you can unpack the lists into the function by prefixing it with an asterisk like this:
コメント
Can i know what’s the practical use of this trick ?
If someone does this in my repo they catching these hands irl fr fr on god
I don’t know if this counts as unpacking trick but something I’ve learned recently is that if you have an iterable, say a list, and you want to pass its contents to a function individually, you can unpack the lists into the function by prefixing it with an asterisk like this:
my_func(*my_list)
Instead of having to write:
my_func(my_list[0], my_list[1], my_list[2]…..