unexpected from/import statement behaviour

alex23 wuwei23 at gmail.com
Wed Aug 27 19:28:01 EDT 2008


On Aug 27, 5:42 pm, "Diez B. Roggisch" <de... at nospam.web.de> wrote:
> alex23 schrieb:
>
>
>
> > 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
> > True
>
> > 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.

No, I read it, I just totally didn't parse it that way :)

Sorry for the confusion, nisp.




More information about the Python-list mailing list