Code Maven

Welcome to the Code Maven!

The main topics

Programming Exercises for any language.


Python: Capture standard output, standard error, and the exit code of a subprocess

I might be missing the obvious, but I don't think the subprocess module has a method that will capture the standard output, standard error, and the exit code of a subprocess in a single call. It is not complex to write one and can be useful.


Python: Capture standard output, standard error, and the exit code of a subprocess


Python: seek - move around in a file and tell the current location

When we open a file for reading with Python (thought this is true for any programming lanuage), we get a filehandle that points to the beginning of the file. As we read from the file the pointer always points to the place where we ended the reading and the next read will start from there.

That is, unless we tell the filehandle to move around.

The tell method of the filehandle will return the current location of this pointer.

The seek method will move the pointer.


Python: seek - move around in a file and tell the current location


Digital Ocean Virtual Private Server Hosting