Expanding tuples into arguments

后端 未结 5 1575
逝去的感伤
逝去的感伤 2020-11-22 11:39

Is there a way to expand a Python tuple into a function - as actual parameters?

For example, here expand() does the magic:

some_tuple =          


        
5条回答
  •  醉梦人生
    2020-11-22 12:36

    Take a look at the Python tutorial section 4.7.3 and 4.7.4. It talks about passing tuples as arguments.

    I would also consider using named parameters (and passing a dictionary) instead of using a tuple and passing a sequence. I find the use of positional arguments to be a bad practice when the positions are not intuitive or there are multiple parameters.

提交回复
热议问题