INNER CODE UNIT · Python

__format_list

dhondta/python-codext · src/codext/__init__.py:33

def __format_list(items, include=True):
    if items is None:
        return
    d = {-1: list_encodings() if include else []}
    for n, i in enumerate(items):
        try:
            depth, i = i.split(":")
            depth = int(depth.strip().replace("~", "-"))
            if depth < 0:
                depth = -1
        except ValueError:
            if n == 0:
                d[-1] = []
            depth = -1
        d.setdefault(depth, [])
        d[depth].append(i.strip())
    return d

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…