Relative-importing *

Marc 'BlackJack' Rintsch bj_666 at gmx.net
Tue Aug 7 02:21:29 EDT 2007


On Tue, 07 Aug 2007 02:45:23 +0000, rbygscrsepda wrote:

> Specifically, in Python 1.5, all of the following generate the error
> below:

In Python *1.5*!?  I somehow doubt that.  ;-)

>     from . import *
>     from .sibiling_package import *
>     from .. import *
>     from ..cousin_package import *
> 
>     SyntaxError: 'import *' not allowed with 'from .'
> 
> Importing * is a feature, but this seems like an artificial
> inconsistency to me. It's as if the compiler raises an error when it
> tries to import * as soon as it sees "from .", regardless of what
> comes after it. So is this a bug in python? And if it happens to be a
> bug, how can I alert the developers of the python compiler?

I'm just guessing here but as * imports are considered bad style the
developers might took the opportunity to forbid them in relative imports
because relative imports are new and this doesn't break old programs.

Ciao,
	Marc 'BlackJack' Rintsch



More information about the Python-list mailing list