[Tutor] Apparent incosistency with Python interperter in IDLE

2009-06-18 Thread Karen Palen

I am an experienced C/C++/C# programmer who is just starting out with Python. 
My first attempt at IDLE worked great with the tutorial, but seems to have a 
problem with my first real app!

I am trying to get the Python subprocess/Popen module working with the example 
from the Python 3 documentation page:
 import subprocess
 subprocess.call('ls')
ArchiveFirefox_wallpaper.png  result.txt ...

which is what I expect.

However this same input to the IDLE Python Shell yields:

Python 3.0.1+ (r301:69556, Apr 15 2009, 15:59:22) 
[GCC 4.3.3] on linux2
Type copyright, credits or license() for more information.
 No Subprocess 
 import subprocess
 subprocess.call('ls')
0
 


Which appears to be merely the return code, not the stdout!

It looks like I need to set some variable in IDLE, but I can't figure out 
exactly what is needed here.

Can anyone point me to an answer?

Karen


  
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Apparent incosistency with Python interperter in IDLE

2009-06-18 Thread Karen Palen

Yes I see.

Based on other feedback I am leaning towards not using any IDE for the moment.

Python seems well adapted to that kind of workflow, as well as an impressive 
portability - every bit as good a Java from my tests so far.

Karen 

--- On Thu, 6/18/09, Lie Ryan lie.1...@gmail.com wrote:

 From: Lie Ryan lie.1...@gmail.com
 Subject: Re: [Tutor] Apparent incosistency with Python interperter in IDLE
 To: tutor@python.org
 Date: Thursday, June 18, 2009, 10:20 AM
 Luke Paireepinart wrote:
  So the problem is that the stdout of the ls command
 is appearing in
  some location that you cannot see.
  As for ways to remedy this - I don't know.  The
 idea here, though, is
  that even though the regular Python version has the
 side-effect that it
  outputs it in the console, that's not necessarily what
 you want it to
  do.  The reason is that you have no way to access
 that data.
 
 You have to explicitly redirect the stdout from subprocess
 
 subprocess.Popen(['ls'], stdout=...)
 
 What you're seeing is a side effect of the nature of the
 interactive
 console and IDLE. The defined behavior of python is when it
 is being run
 from a script.
 
 ___
 Tutor maillist  -  Tutor@python.org
 http://mail.python.org/mailman/listinfo/tutor
 


  
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor