[Python-3000] from .foo import *
"Martin v. Löwis"
martin at v.loewis.de
Tue Mar 18 16:23:41 CET 2008
When I do a relative star import, I current get
SyntaxError: 'import *' not allowed with 'from .'
What's the reason for this restriction?
Is it ok to remove it?
I encountered the issue while porting Django. In
django/newforms/__init__.py, they do
from widgets import *
from fields import *
from forms import *
from models import *
In 3k, that needs to change to
from .widgets import *
from .fields import *
from .forms import *
from .models import *
but that still won't work because of the syntax
error. One solution would be to make the import
explicit, but that is tedious and unmaintainable.
E.g. for the widgets line, it would be
from .widgets import (Widget, TextInput, PasswordInput,
HiddenInput, MultipleHiddenInput,
FileInput, DateTimeInput, Textarea, CheckboxInput,
Select, NullBooleanSelect, SelectMultiple, RadioSelect,
CheckboxSelectMultiple, MultiWidget, SplitDateTimeWidget)
Regards,
Martin
More information about the Python-3000
mailing list