[Tutor] os.sys

Andrew Nelsen sxkorean at gmail.com
Sun Oct 28 18:01:24 CET 2007

On 10/28/07, Lawrence Shafer <detroit371 at gmail.com> wrote:
> Why doesn't this fill otp with the output of ls?? (I know python has
> it's own file tools, I'm just playing around ;)
> import os
> cmd="""ls"""
> otp=os.system(cmd)
> print otp
> _______________________________________________
> Tutor maillist  -  Tutor at python.org

 I actually had the same question a while back. I'm still a newbie, but the
advice I was given was  to use popen(). ls = os.popen("ls").read() worked
for me. Also, for Unix style OSes, you can import commands, and then it has
Just my two cents.

- Drew
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/tutor/attachments/20071028/5c8d3e21/attachment.htm 

More information about the Tutor mailing list