How to set auto-width for text rows in Python

I have the python-function:

def myFunction(inputList):
    outputList = ['Path      |      Type      |      Size']
    for item in inputList:
        outputList.append(item + '      |      ' + parseFileType(item) + '      |      ' + parseFileSize(item))
    return outputList

And I have following output from this function:

Path      |      Type      |      Size
/etc/acpi       |      directory      |      16 Kb.
/etc/adduser.conf       |      ASCII text      |      4,0 Kb.
/bin/df |      ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, for GNU/Linux 2.6.32, BuildID[sha1]=8b0d9cd8d2256a94b9ea7e2248b6d8721cff588d, stripped      |      84 Kb.

How can I make auto-width for text output from this function, for it looks like:

Path                |      Type           |      Size
/etc/acpi           |      directory      |      16 Kb.
/etc/adduser.conf   |      ASCII text     |      4,0 Kb.
...


Read more here: https://stackoverflow.com/questions/68491812/how-to-set-auto-width-for-text-rows-in-python

Content Attribution

This content was originally published by mshta at Recent Questions - Stack Overflow, and is syndicated here via their RSS feed. You can read the original post over there.

%d bloggers like this: