unexpected from/import statement behaviour
Diez B. Roggisch
deets at nospam.web.de
Wed Aug 27 09:42:00 CEST 2008
> nisp <emanuele.nesp... at gmail.com> wrote:
>> I've always been convinced of the equivalence of the two ways of using
>> the import statement but it's clear I'm wrong :-(
> Python 2.5.2 (r252:60911, Jul 31 2008, 17:28:52)
> [GCC 4.2.3 (Ubuntu 4.2.3-2ubuntu7)] on linux2
> Type "help", "copyright", "credits" or "license" for more information.
>>>> from sys import stderr
>>>> import sys
>>>> sys.stderr is stderr
> Behaviourly, I'm finding no difference between the two either.
> Could you cut & paste a minimal example that isn't producing the
> correct behaviour, and perhaps mention what type of OS you're using?
You did not read this part of the post:
I'm not able to capture its stderr and of course I would like not to
do this kind of change.
He tries to set sys.stderr to a new stream and capture the print
statements, but fails to do so because he created a local alias.
More information about the Python-list