Files
pyfa/gui/utils/listFormatter.py
2012-03-19 16:43:35 +04:00

10 lines
283 B
Python

def formatList(words):
"""Transforms ("a", "b", "c") into "a, b and c" string"""
if not words:
return ""
if len(words) == 1:
return words[0]
last = words[-1:][0]
beginning = u", ".join(words[:-1])
return u"{0} and {1}".format(beginning, last)