[Python-3000] from .foo import *

Thomas Wouters thomas at python.org
Tue Mar 18 16:38:08 CET 2008


On Tue, Mar 18, 2008 at 8:32 AM, Guido van Rossum <guido at python.org> wrote:

> 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 don't recall any such issues, and I can't imagine them now. The '.' is
resolved before the fromlist is even considered, and is just a way to find
the right package to import from. Importing '*' instead of a set of names
should not be a problem.


>
> 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/<http://www.python.org/%7Eguido/>
> )
> _______________________________________________
> 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/thomas%40python.org
>



-- 
Thomas Wouters <thomas at python.org>

Hi! I'm a .signature virus! copy me into your .signature file to help me
spread!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/python-3000/attachments/20080318/ecd16f8d/attachment-0001.htm 


More information about the Python-3000 mailing list