Advertisement
here2share

# list_unpack_with_single_star.py

Sep 5th, 2015
256
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.29 KB | None | 0 0
  1. # list_unpack_with_single_star.py
  2.  
  3. # The single star (*) unpacks the sequence/collection into positional arguments, so you can do this...
  4.  
  5. def sum(a, b):
  6.     return a + b
  7.  
  8. values = (1, 2)
  9.  
  10. print sum(*values)
  11. # This will unpack the tuple so that it actually executes as...
  12.  
  13. print sum(3, 6)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement