[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

Re: svn commit: rev 3734 - trunk/subversion/tests/clients/cmdline

From: Greg Stein <gstein_at_lyra.org>
Date: 2002-11-12 04:49:22 CET

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.

The only 'type' in this discussion is a module.

>...
> > >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. There is no need to "import os
explicitly" as that is exactly what "import os.path" is doing.

> > I think it's good style to import os.path and not os, it all we're using
> > is stuff from the os.path module.

It doesn't matter, and I'd leave it to personal preference. Nowadays, I just
"import os" as os.path is always going to be there. I can see the argument
that "if we're just using os.path function, then this import helps to
clarify the scope of stuff we're using". Of course, once the module starts
using stuff from "os", then that implicit explanation is wrong. Because of
this "grow to use os stuff", I just stick with import os and nothing more.

> 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 :-)

>...
> 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 :-)

Cheers,
-g

-- 
Greg Stein, http://www.lyra.org/
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Tue Nov 12 05:48:08 2002

This is an archived mail posted to the Subversion Dev mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.