Re: PEP 420: Implicit Namespace Packages
Brett Cannon <[email protected]>
| Newsgroups | gmane.comp.python.import |
|---|---|
| Message-ID | <CAP1=2W4+bEmFYF-kP+71Mu2EXbQYHia=sc0YPAgAB3Y7Z0QY2g@mail.gmail.com> |
On Wed, May 2, 2012 at 2:32 PM, "Martin v. Löwis" <[email protected]>wrote: > On 02.05.2012 12:23, Eric V. Smith wrote: > >> On 5/2/2012 3:17 AM, "Martin v. Löwis" wrote: >> >>> About the only question I have is: Is everyone okay with the changes to >>>> the finders, described in the PEP? >>>> >>> >>> It looks good to me. It's a somewhat surprising change, but I can see no >>> flaw in it. >>> >> >> Surprising in that any change to find_module is needed, or surprising >> that it now returns one of {None, loader, str}? >> >> > Both, actually. I had expected that new API (i.e. a new method of some > kind) would be necessary, so it has elegance that this is not required. > OTOH, explicit type checking is despised in the OO world, and varying > result types are disliked by Guido van Rossum (not sure whether this > reservation applies to this case as well, or only to cases where the > return type depends on the parameter types). > You actually don't need to explicitly type-check and instead can rely on duck typing:: if loader is None: continue elif hasattr(loader, 'load_module'): return loader else: namespace.append(loader) continue _______________________________________________ Import-SIG mailing list [email protected] http://mail.python.org/mailman/listinfo/import-sig