Mega Code Archive

 
Categories / Python / Tuple
 

A tuple with one item

# A tuple with one item is constructed by following a value with a comma  # (it is not sufficient to enclose a single value in parentheses).  # Ugly, but effective. For example: singleton = 'hello',    # <-- note trailing comma print len(singleton) print singleton