[Tutor] how to get variable from an external script or program

shawn bright nephish at gmail.com
Sat May 30 00:30:31 CEST 2009


cool, thanks again
sk

On Fri, May 29, 2009 at 5:09 PM, Alan Gauld <alan.gauld at btinternet.com> wrote:
>
> "vince spicer" <vinces1979 at gmail.com> wrote
>>
>> import commands
>> output = commands.getout("ls -lah")
>
> There are many ways to do this in Python including os.popen, commands and
> subprocess.
>
> But subprocess is the "officially correct" version, the others are
> deprecated and could theoretically disappear in a future version of Python.
> (But not soon I suspect because of the amount of legacy code that uses it!)
>
> But its definitely worth weaning oneself onto subprocess even though it is
> initially harder work. In the end the superior flexibility and consistency
> of approach pay back.
>
> Alan G.
>
>
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> http://mail.python.org/mailman/listinfo/tutor
>


More information about the Tutor mailing list