Greg Stein <gstein@lyra.org> writes:
> On Mon, Nov 11, 2002 at 03:09:11PM -0800, Daniel Rall wrote:
> > =?UTF-8?B?QnJhbmtvIMSMaWJlag==?= <brane@xbc.nu> writes:
> >
> > > Daniel Rall wrote:
> > >
> > > >Minor detail regarding os.path in the Subversion Python code; path is
> > > >a variable of the os module (of type "posixpath"),
>
> Woah... if you're going to throw terms around, especially as the basis of an
> argument, then please get them right :-)
>
> "os" and "path" are both names. They are bound to specific objects. Those
> objects are both modules. The module bound to "os" is from Lib/os.py. The
> module bound to "os.path" is variable, based on the platform.
Okay, I wasn't aware that a "name" was formal -- that is what I meant
by "variable." With my usage above, per your explanation and the docs
it's actually a "module" in the context of an import statement (even
if the implementation of it is a little odd, being bound to a "name"
in the os module).
http://www.python.org/doc/current/ref/import.html
...
> >...
> > > >thus importing
> > > >os.path actually imports the os module. We might as well stop fooling
> > > >ourselves and import os explicitly (rather than importing os.path).
>
> Bah. That is rather non-sensical. The *definition* of importing from a
> package has always been to create a name in the namespace pointing to the
> top-most package in the import command.
Do you mean "pointing ot the top-most module" rather than "package?"
> There is no need to "import os explicitly" as that is exactly what
> "import os.path" is doing.
Okay. Thanks to your gentle tutelage, _now_ I know.
...
> > os.path is a variable; it just happens to reference a module. It
>
> And "os" is just a variable, too. Don't try using this argument :-)
I thought it was a "name?" ;-)
> >...
> > http://www.python.org/peps/pep-0008.html is related and is good
> > reading, but doesn't address this topic directly. The "A Foolish
> > Consistency is the Hobgoblin of Little Minds" section is probably my
> > favorite part.
>
> Yes, this is a good PEP for anybody writing Python code. In particular, it
> also mentions one module per import (relevant to the change in this commit).
> IOW, rather than:
>
> import os, sys, types
>
> do:
>
> import os
> import sys
> import types
>
> With blank lines between groupings. (of course, I like my C variable
> declarations like this, too, so it isn't surprising that I agree with this
> point of Python style :-)
This is my preferred style as well. It was funny to run into that doc
and read exactly what I've been doing for several years in various
languages.
--
Daniel Rall <dlr@finemaltcoding.com>
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Tue Nov 12 18:57:20 2002