Join us and get access to hundreds of tutorials and a community of expert Pythonistas.
Unlock This Lesson
This lesson is for members only. Join us and get access to hundreds of tutorials and a community of expert Pythonistas.
Python args and kwargs: Demystified
DJ on Jan. 13, 2020
*a, = "RealPython"
a with a trailing comma seems to be a list type, not a tuple
zuckerjohn on Jan. 23, 2020
Good observation ‘GJ’, I think you are right.
Here to demonstrate.
>>> a = [‘Python, bytes’]
>>> b, = ‘Python, bytes’
>>> a == b
>>> a == tuple(b)
There may be some transferred confusion from a comma idiosyncracy as follows
Karan Khosla on Feb. 26, 2020
def sum(*args): # Returns a tuple values
my_list = [1, 2, 3, 4, 5]
a, *b, c = my_list
Here, *b returns a list not a tuple? What am missing here. Please help.
Cristian Palau on May 8, 2020
Thanks for the course!
Become a Member to join the conversation.