[Python-Dev] Of what use is commands.getstatus()
Guido van Rossum
guido@python.org
Fri, 23 May 2003 09:11:35 -0400
> I was reading the docs for the commands module and noticed getstatus() seems
> to be completely unrelated to getstatusoutput() and getoutput(). I thought,
> "I'll correct the docs. They must be wrong." Then I looked at commands.py
> and saw the docs are correct. It's the function definition which is weird.
> Of what use is it to return 'ls -ld file'? Based on its name I would have
> guessed its function was
>
> def getoutput(cmd):
> """Return status of executing cmd in a shell."""
> return getstatusoutput(cmd)[0]
>
> This particular function dates from 1990, so it clearly can't just be
> deleted, but it seems completely superfluous to me, especially given the
> existence of os.stat, os.listdir, etc. Should it be deprecated or modified
> to do (what I think is) the obvious thing?
That whole module wasn't thought out very well. I recently tried to
use it and found that the strip of the trailing \n on getoutput() is
also a counterproductive feature. I suggest that someone should
design a replacement, perhaps to live in shutil, and then we can
deprecate it. Until then I would leave it alone. Certainly don't
"fix" it by doing something incompatible.
--Guido van Rossum (home page: http://www.python.org/~guido/)