Why use backticks?

Jeff Epler jepler at unpythonic.net
Wed May 7 21:29:54 EDT 2003


On Wed, May 07, 2003 at 05:16:38PM -0500, Paul Watson wrote:
> Backticks in Python do not mean the same thing as they do in Perl.  Your
> Perl friend would need to do something like:

.. or they could use the commands module.
>>> commands.getoutput("uname -a")
'Linux parrot 2.4.20-9 #1 Wed Apr 2 13:42:50 EST 2003 i686 i686 i386
GNU/Linux'

I notice this even has the last-newline-stripping feature of Perl's ``.
(I also don't see how to turn this off, in case the program's output is
binary...)

Jeff





More information about the Python-list mailing list