Python pty module usage example
Question: What I need to do is the following: in a Python script spawn, say the "ls
--colors=always /" Linux command, and read its output. The important part of
this is that I need the output to keep all the ANSI escape sequences (colors
and such) to later translate these sequences into HTML. I heard that Python
pty module can do that, but I could not find a useful example of its usage in
the Internet, and this module's documentation is not quite comprehensive. I'll
appreciate if someone could guide me through the way of accomplishing this
task.


Answer: 
    import subprocess as sub
    
    process = sub.Popen("ls --colors=always /", stdout=sub.PIPE, stderr=sub.PIPE)
    output, errors = process.communicate()
    

Now all the data you want should be in `output` \- including the ANSI escape
sequences.

