Re: [Python-Dev] Writing importers and path hooks

2013-03-29 Thread Nick Coghlan
On Fri, Mar 29, 2013 at 3:39 AM, Brett Cannon wrote: > To tell if a module is a package, you should do either ``if mod.__name__ == > mod.__package__`` or ``if hasattr(mod, '__path__')``. The second of those is actually a bit more reliable. As with many import quirks, the answer to "But why?" is "

Re: [Python-Dev] Writing importers and path hooks

2013-03-28 Thread Brett Cannon
On Thu, Mar 28, 2013 at 12:33 PM, Paul Moore wrote: > On 28 March 2013 16:08, Brett Cannon wrote: > > You only need SourceLoader since you are dealing with Python source. You > > don't need FileLoader since you are not reading from disk but an > in-memory > > zipfile. > > > > You should be imple

Re: [Python-Dev] Writing importers and path hooks

2013-03-28 Thread Paul Moore
On 28 March 2013 16:08, Brett Cannon wrote: > You only need SourceLoader since you are dealing with Python source. You > don't need FileLoader since you are not reading from disk but an in-memory > zipfile. > > You should be implementing get_data, get_filename, and path_stats for > SourceLoader.

Re: [Python-Dev] Writing importers and path hooks

2013-03-28 Thread Brett Cannon
On Thu, Mar 28, 2013 at 11:38 AM, Paul Moore wrote: > On 28 March 2013 13:42, Brett Cannon wrote: > >> importer, as I wanted to try a proof of concept importer based on the > >> new importlib stuff (which is intended to make writing custom > >> importers easier), and I really struggled to get so

Re: [Python-Dev] Writing importers and path hooks

2013-03-28 Thread Paul Moore
On 28 March 2013 13:42, Brett Cannon wrote: >> importer, as I wanted to try a proof of concept importer based on the >> new importlib stuff (which is intended to make writing custom >> importers easier), and I really struggled to get something working. > > Struggling how? With the finder? The load

Re: [Python-Dev] Writing importers and path hooks

2013-03-28 Thread Brett Cannon
On Wed, Mar 27, 2013 at 6:59 PM, Paul Moore wrote: > On 27 March 2013 21:19, Bradley M. Froehle wrote: > > I implemented just such a path hook zipimporter plus the magic > required > > for C extensions --- as a challenge to myself to learn more about the > Python > > import mechanisms. > >