unexpected from/import statement behaviour

nisp emanuele.nespolo at gmail.com
Wed Aug 27 03:14:53 EDT 2008


Hi all !

I'm trying to capture stderr of an external module I use in my python
program. I'm doing this
by setting up a class in my module overwriting the stderr file object
method write.
The external module outputs to stderr this way:

from sys import std err

....

	print >> stderr, "Some text"

While in my module I use

import sys

	..... sys.stderr ... sys.stdout

Well, as long as I do not change in the external module those from/
import statements to just

import sys

....

	print >> sys.stderr, "Some text"

I'm not able to capture its stderr and of course I would like not to
do this kind of change.
I've always been convinced of the equivalence of the two ways of using
the import statement
but it's clear I'm wrong :-(

Please, someone can tell me what's going on ?

Thanks in advance !



More information about the Python-list mailing list