Beginner question: Converting Single-Element tuples to list

Paul McGuire ptmcg at austin.rr.com
Mon Jun 27 07:13:52 CEST 2005


('abc') is not a tuple - this is an unfortunate result of using ()'s as
expression grouping *and* as tuple delimiters.  To make ('abc') a
tuple, you must add an extra comma, as ('abc',).

>>> list( ('abc',) )
['abc']

-- Paul




More information about the Python-list mailing list