Hi Tim,
Yes, you're on the right track.
a,b,c = os.popen3('wt *.py','r')
res = a.read()
The error you're getting has nothing to do with the result of the
command, but check, from the docs:
popen3( cmd[, mode[, bufsize]])
Executes cmd as a sub-process. Returns the file objects (child_s
Hey Hugo:
I now realize that to properly test this, I should use a command that
returns legitimate data:
I think the following gets me started:
f = os.popen('ls *.py','r').read()
now I have captured the output from 'ls *.py'.
So, if I do this with popen3:
>>> a,b,c = os.popen3('wt *.py','r')
>>>
I also noticed that if you want to get the manpage, you will be hurt by
the interactivity of 'man' (it uses less for paging) One way to get the
whole manpage as text without paging is to do:
man -P /bin/cat
So you won't have to do strange stuff in stdin to get it to give you the
whole text.
H
Hi Tim,
You are correctly using the filehandles you have, but the man command
must be sending the response into STDERR instead of STDOUT. This makes
sense, since it is an error message.
Take a look at popen4() and popen3() which both let you catch the
standard error of a process. Also, in mor
Hi:
I've got a question about popen2.
Consider the following code: (on linux)
import popen2
fin, fout = popen2.popen2("man nothere")
## interpreter outputs the following:
No manual entry for nothere
The following queries of the returned file objects
give the following:
>>> fin
', mode 'r' at 0x4
Michael Broe wrote:
> I just discovered the following behavior, but can't find any
> documentation about it:
>
> >>> list = []
> >>> list = list + 'abc'
> Traceback (most recent call last):
>File "", line 1, in ?
> TypeError: can only concatenate list (not "str") to list
>
> but:
>
> >>
I just discovered the following behavior, but can't find any
documentation about it:
>>> list = []
>>> list = list + 'abc'
Traceback (most recent call last):
File "", line 1, in ?
TypeError: can only concatenate list (not "str") to list
but:
>>> list = []
>>> list += 'abc'
>>> list
['a
This works for me under Python 2.4 -
import math
math.sqrt(4)
When you state "Sqrt is listed as always available", where does it say that?
For future problem reports, let us know which Python release you are
running.
-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On
Kermit Rose wrote:
> Sqrt is listed as always available.
>
Where did you see that?
Try:
>>> import math
>>> math.sqrt(24)
4.8989794855663558
> Why did I get these diagnostics?
>
>
>
Sqrt(J0)
>
> Traceback (most recent call last):
> File "", line 1, in -toplevel-
>
Sqrt is listed as always available.
Why did I get these diagnostics?
>>> Sqrt(J0)
Traceback (most recent call last):
File "", line 1, in -toplevel-
Sqrt(J0)
NameError: name 'Sqrt' is not defined
>>>
>>> sqrt(J0)
Traceback (most recent call last):
File "", line 1, in -toplevel-
s
Michael Lange wrote:
> On Wed, 15 Feb 2006 22:05:39 +1100
> "John Connors" <[EMAIL PROTECTED]> wrote:
> I have a copy of Teach Yourself Python in 24 Hours,
printed in 2000 so I guess it's virtually usless but i was hoping to
learn some of the basics from it.
>
> I don't think the book is completel
On Wed, 15 Feb 2006 22:05:39 +1100
"John Connors" <[EMAIL PROTECTED]> wrote:
> G'day, I'm new to Python and new to the list and just thought I'd say a quick
> hello before asking my 1st dumb question. My name is John and I live in
> Australia, I've been using computers since about 1983. I haven
G'day, I'm new to Python and new to the list and just thought I'd say a quick hello before asking my 1st dumb question. My name is John and I live in Australia, I've been using computers since about 1983. I haven't done any programming since the commodore 64 basic days, I was fairly proficient w
13 matches
Mail list logo