octave-maintainers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: popen2 example gives no output


From: Stefan van der Walt
Subject: Re: popen2 example gives no output
Date: Sat, 24 Sep 2005 15:04:36 +0200
User-agent: Mutt/1.5.9i

On Sat, Sep 24, 2005 at 08:49:05AM -0400, John W. Eaton wrote:
> On 24-Sep-2005, Stefan van der Walt wrote:
> 
> | Maybe something like
> | 
> | ${PYTHON} -c '
> | from errno import errorcode
> | from string import Template, join
> | from sys import stdin
> | 
> | t = Template("#if defned (\$e)\n{ \"$e\", $e, },\n#endif\n")
> | errstr = join([t.substitute(e=errorcode[i]) for i in errorcode.keys()])
> | 
> | for l in stdin:
> |     print l.replace("@SYSDEP_ERRNO_LIST@", errstr),
> | '
> 
> On my system (with Python 2.3.5) This fails for me with the following
> error:
> 
>   Traceback (most recent call last):
>     File "<string>", line 3, in ?
>   ImportError: cannot import name Template

Yes, this is a Python 2.4 feature.  You can do something like

PYTHON=python

${PYTHON} -c '
from errno import errorcode
from string import Template, join
from sys import stdin

t = "#if defined (\%s)\n{ \"%s\", %s, },\n#endif\n"
errstr = ""
for k in errorcode.keys():
    errstr += t % tuple(3*[errorcode[k]])

for l in stdin:
    print l.replace("@SYSDEP_ERRNO_LIST@", errstr),
'

Regards
Stéfan



reply via email to

[Prev in Thread] Current Thread [Next in Thread]