Python Unpacking trick you probably didn’t know about

学習

コメント

  1. @Cheesecake99YearsAgo より:

    Can i know what’s the practical use of this trick ?

  2. @trentonsmith8739 より:

    If someone does this in my repo they catching these hands irl fr fr on god

  3. @kalelodukuray6141 より:

    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]…..

タイトルとURLをコピーしました