[rfc] use absolute imports
Andrew Bennetts
andrew at canonical.com
Thu Feb 22 00:22:23 GMT 2007
John Arbash Meinel wrote:
> Martin Pool wrote:
> > After a conversation with John I thought I'd try enabling absolute
> > imports. However, it looks like there's no clean way to turn these on
> > only on python2.5, since they can't be guarded by an if or try/except
> > block. Nevertheless I think our code should always use 'import
> > bzrlib.foo' not 'import foo'.
>
> I would be for this, since it is something we would like to do.
>
> The only downside is plugins. Because they don't always know where they
> are installed, so I've taken to using local imports there.
Can't the plugins do "from bzrlib.plugins.foo import ..."?
>
> If this only changes it for a specific file we don't affect plugins, but
> then again we don't affect the rest of our code base either. (And I
> don't think we want to add that line to every file).
I think whenever we require python2.5 ideally we would add this to every file in
bzr. Ugly though it is to have a __future__ statement in every file, it will
enforce the right sort of behaviour (and make sure we're compatible with future
releases of python that will do this by default).
I wonder if we can make lazy_import refuse to do a relative import?
-Andrew.
More information about the bazaar
mailing list