unexpected from/import statement behaviour
Diez B. Roggisch
deets at nospam.web.de
Wed Aug 27 03:19:11 EDT 2008
nisp schrieb:
> 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 ?
http://effbot.org/zone/import-confusion.htm
Diez
More information about the Python-list
mailing list