You are viewing an older version (9.5.0). Go to latest (9.13.0)
{ } Raw JSON

bundles / IPython 9.5.0 / IPython / utils / text / get_text_list

function

IPython.utils.text:get_text_list

source: /IPython/utils/text.py :622

Signature

def   get_text_list ( list_ : List[str] last_sep : str = and sep : str = , wrap_item_with : str = '' )  →  str

Summary

Return a string with a natural enumeration of items

Extended Summary

>>> get_text_list(['a', 'b', 'c', 'd'])
'a, b, c and d'
>>> get_text_list(['a', 'b', 'c'], ' or ')
'a, b or c'
>>> get_text_list(['a', 'b', 'c'], ', ')
'a, b, c'
>>> get_text_list(['a', 'b'], ' or ')
'a or b'
>>> get_text_list(['a'])
'a'
>>> get_text_list([])
''
>>> get_text_list(['a', 'b'], wrap_item_with="`")
'`a` and `b`'
>>> get_text_list(['a', 'b', 'c', 'd'], " = ", sep=" + ")
'a + b + c = d'

Aliases

  • IPython.utils.text.get_text_list