[Python-3000] from .foo import *

Guido van Rossum guido at python.org
Tue Mar 18 16:32:33 CET 2008


I don't recall the reason; it may simply be due to the complexity, or
possibly it would have made the _import__ API even uglier.

I'm fine with removing the restriction; your use case is compelling.

On Tue, Mar 18, 2008 at 10:23 AM, "Martin v. Löwis" <martin at v.loewis.de> wrote:
> 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
>  _______________________________________________
>  Python-3000 mailing list
>  Python-3000 at python.org
>  http://mail.python.org/mailman/listinfo/python-3000
>  Unsubscribe: http://mail.python.org/mailman/options/python-3000/guido%40python.org
>



-- 
--Guido van Rossum (home page: http://www.python.org/~guido/)


More information about the Python-3000 mailing list