[Tutor] updating Unix config file
Matt Herzog
msh at blisses.org
Tue Oct 20 19:00:06 CEST 2009
On Tue, Oct 20, 2009 at 07:53:17AM -0700, Steve Willoughby wrote:
> On Tue, Oct 20, 2009 at 10:44:16AM -0400, Matt Herzog wrote:
> > Yes, thanks. What failed was the invocation of PIPE. Apparently I had to explicitly import PIPE from subprocess or python had no clue as to what PIPE was!
> >
> > Dare I say, "wtf?" since when fo I have to specify such? Shouldn't importing the subprocess module make all its methods available? I can't remember having to do this before.
>
I have been reading python books and trying to learn python for about a year now and this has never met my attention before. Thanks.
> It's always been like that. Otherwise we'd have lots of collisions between module global
> names that namespaces are designed to avoid in the first place. So you either name them
> explicitly, or import them explicitly:
>
> import subprocess
> # now you can reference subprocess.PIPE
>
> --or--
>
> from subprocess import Popen, PIPE
> # now you can reference PIPE without the namespace identifier
>
> --or--
>
> from subprocess import *
> # but I don't recommend this one (caution! danger!)
>
--
The test of a first-rate intelligence is the ability to hold two opposed ideas in the mind at the same time, and still retain the ability to function.
-- F. Scott Fitzgerald
More information about the Tutor
mailing list