[Import-SIG] making it feasible to rely on loaders for reading intra-package data files

Brett Cannon brett at python.org
Mon Feb 3 17:54:50 CET 2014


On Sun, Feb 2, 2014 at 8:50 AM, Paul Moore <p.f.moore at gmail.com> wrote:

> On 1 February 2014 18:44, Brett Cannon <brett at python.org> wrote:
> > Over on distutils-sig it came up that getting people to not simply assume
> > that __file__ points to an actual file and thus avoid using open()
> directly
> > to read intra-package files is an issue. In order to make using a
> loader's
> > get_data reasonable (let alone set_data), there needs to be a clear
> > specification of how things are expected to work and make sure that
> > everything that people need is available.
>
> An alternative suggestion - now that Python 3.4 has pathlib, how
> practical would it be to create a ZipFilePath subclass that acted as a
> concrete path for files in a zipfile? Getting people to use pathlib
> for dealing with __file__ rather than the old os.path functions might
> be an easier sell, and if pathlib handled zipfiles "behind the scenes"
> we could avoid the whole issue.
>

Interesting idea, but I don't know how backwards-compatible it would be.
But since pathlib itself has several subclasses I don't see why there
couldn't be some way to construct something that understood what part of a
path was a zipfile and what was a path within the zipfile.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/import-sig/attachments/20140203/6082d305/attachment.html>


More information about the Import-SIG mailing list