Show More
@@ -726,15 +726,17 b" def columnize(items, separator=' ', displaywidth=80):" | |||
|
726 | 726 | return '\n'.join(map(sjoin, fmatrix))+'\n' |
|
727 | 727 | |
|
728 | 728 | |
|
729 |
def get_text_list(list_, last_ |
|
|
729 | def get_text_list(list_, last_sep=' and ', sep=", ", wrap_item_with=""): | |
|
730 | 730 | """ |
|
731 | 731 | Return a string with a natural enumeration of items |
|
732 | 732 | |
|
733 | 733 | >>> get_text_list(['a', 'b', 'c', 'd']) |
|
734 | 734 | 'a, b, c and d' |
|
735 | >>> get_text_list(['a', 'b', 'c'], 'or') | |
|
735 | >>> get_text_list(['a', 'b', 'c'], ' or ') | |
|
736 | 736 | 'a, b or c' |
|
737 |
>>> get_text_list(['a', 'b' |
|
|
737 | >>> get_text_list(['a', 'b', 'c'], ', ') | |
|
738 | 'a, b, c' | |
|
739 | >>> get_text_list(['a', 'b'], ' or ') | |
|
738 | 740 | 'a or b' |
|
739 | 741 | >>> get_text_list(['a']) |
|
740 | 742 | 'a' |
@@ -742,6 +744,8 b' def get_text_list(list_, last_word=\'and\', wrap_item_with=""):' | |||
|
742 | 744 | '' |
|
743 | 745 | >>> get_text_list(['a', 'b'], wrap_item_with="`") |
|
744 | 746 | '`a` and `b`' |
|
747 | >>> get_text_list(['a', 'b', 'c', 'd'], " = ", sep=" + ") | |
|
748 | 'a + b + c = d' | |
|
745 | 749 | """ |
|
746 | 750 | if len(list_) == 0: |
|
747 | 751 | return '' |
@@ -750,6 +754,6 b' def get_text_list(list_, last_word=\'and\', wrap_item_with=""):' | |||
|
750 | 754 | item in list_] |
|
751 | 755 | if len(list_) == 1: |
|
752 | 756 | return list_[0] |
|
753 |
return '%s |
|
|
754 |
|
|
|
755 |
last_ |
|
|
757 | return '%s%s%s' % ( | |
|
758 | sep.join(i for i in list_[:-1]), | |
|
759 | last_sep, list_[-1]) No newline at end of file |
General Comments 0
You need to be logged in to leave comments.
Login now