Building unique comma-delimited list?

Scott David Daniels Scott.Daniels at Acm.Org
Wed Jan 5 19:19:22 EST 2005


How about (for 2.4 or 2.3 using "from collections import Set as set":

def combine(source, special='foo'):
     parts = set(source)
     if special in parts:
	return ', '.join([special] + list(parts - set([special])))
     return ', '.join(parts)

--Scott David Daniels
Scott.Daniels at Acm.Org




More information about the Python-list mailing list