[Python-Dev] On breaking modules into packages Was: [issue10199] Move Demo/turtle under Lib/

Guido van Rossum guido at python.org
Wed Nov 3 04:01:18 CET 2010


On Tue, Nov 2, 2010 at 7:50 PM, Brett Cannon <brett at python.org> wrote:
> This is not what I am suggesting for PEP 8. I want to say that a
> package's file structure should reflect the public API.

But what does that mean? I could argue that unittest's structure
(TestCase in case.py, etc.) reflects its public API just fine.

> I personally
> have no trouble with modules in packages that do not have a ton of
> objects in them. I just think if you have pkg/mod.py, pkg.mod should
> be exposed in the API, else name the file _mod.py. In the case of
> unittest that would just mean documenting that it's
> unittest.case.TestCase and that unittest.TestCase is for legacy
> reasons, much like os.path is just blindly added on to os even though
> it is a separate module(s).

I really don't think we should encourage the use as
unittest.case.TestCase -- it's unnecessarily introducing structure. I
think it's fine now that the cat is out of the bag to document
unittest.case.TestCase as an alternative spelling, but I don't think
it should be the preferred one.

os.path is so old that should not be taken as an example for anything.
(It predates packages!) But it should not be changed either, there'd
be too  much churn.

-- 
--Guido van Rossum (python.org/~guido)


More information about the Python-Dev mailing list