Just <[EMAIL PROTECTED]> writes:
> In article <[EMAIL PROTECTED]>,
> Simo Melenius <[EMAIL PROTECTED]> wrote:
> > ... sys.stdout = sys.__stdout__
> Aargh, I can't believe how widespread this idiom is :-(. See my other
> reply in this thread: DON'T use sys.__stdout__. Ever.
It probably d
Just schreef:
> You should always save stdout instead of using __stdout__. It may not be
> the same!
You're right, especially when this code would execute in an (at
programming time) unknown context.
--
JanC
"Be strict when sending and tolerant when receiving."
RFC 1958 - Architectural Prin
In article <[EMAIL PROTECTED]>,
Just <[EMAIL PROTECTED]> wrote:
> In article <[EMAIL PROTECTED]>,
> Simo Melenius <[EMAIL PROTECTED]> wrote:
>
> > I've sometimes replaced sys.stdout (and/or sys.stderr) to
> > capture/redirect debugging information in existing code that has
> > unwisely just "pr
(Not sure if my other message arrived)
I am guilty of using this idiom, too.
The standard library
http://www.python.org/dev/doc/devel/lib/module-sys.html#l2h-396
says:
"""
__stdin__
__stdout__
__stderr__
These objects contain the original values of stdin, stderr and
stdout at the start of the p
Just wrote:
> In article <[EMAIL PROTECTED]>,
> Simo Melenius <[EMAIL PROTECTED]> wrote:
>
> > I've sometimes replaced sys.stdout (and/or sys.stderr) to
> > capture/redirect debugging information in existing code that has
> > unwisely just "print"ed error and warning messages, instead of
using
>
In article <[EMAIL PROTECTED]>,
Simo Melenius <[EMAIL PROTECTED]> wrote:
> I've sometimes replaced sys.stdout (and/or sys.stderr) to
> capture/redirect debugging information in existing code that has
> unwisely just "print"ed error and warning messages, instead of using
> sys.stderr or error logg
Ron Garret <[EMAIL PROTECTED]> writes:
> (with-output-to-string (s)
> (let ( (*standard-output* s) )
> (call-html-generating-code)
> s))
>
> Is there an equivalent Python trick to capture a function call's output
> as a string?
I've sometimes replaced sys.stdout (and/or sys.stderr) to
In article <[EMAIL PROTECTED]>,
JanC <[EMAIL PROTECTED]> wrote:
> Something like this:
>
> py> import cStringIO
> py> import sys
> py>
> py> def foo():
> ... print "test"
> ...
> py> f = cStringIO.StringIO()
> py> sys.stdout = f
> py> foo()
> py> s = f.getvalue()
> py> sys.stdout = sys.__std
Ron Garret schreef:
> But this topic does bring up a legitimate question: I have a bunch of
> code that generates HTML using PRINT statements. I need to convert all
> this code to return strings rather than actually printing them (so I can
> use the results to populate templates). In Lisp I c
In article <[EMAIL PROTECTED]>, [EMAIL PROTECTED] (Aahz)
wrote:
> In article <[EMAIL PROTECTED]>,
> Roy Smith <[EMAIL PROTECTED]> wrote:
> >In article <[EMAIL PROTECTED]>,
> > Ron Garret <[EMAIL PROTECTED]> wrote:
> >> In article <[EMAIL PROTECTED]>,
> >> "Erik Bethke" <[EMAIL PROTECTED]> wrot
10 matches
Mail list logo