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.

Unlock This Lesson

Unpacking With the Asterisk Operators

Comments & Discussion

*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]
>>> type(a) 
<class list> 
>>> b, = Python, bytes 
>>> type(b) 
<class list> 
>>> a == b 
True 
>>> a == tuple(b) 
False

There may be some transferred confusion from a comma idiosyncracy as follows

>>> type((singleterm,))
<class tuple> 
>>> type((singleterm)) 
<class str>

Become a Member to join the conversation.