How to import only one module in a package when the package __init__.py has already imports the modules?

Wolodja Wentland wentland at cl.uni-heidelberg.de
Sat Oct 31 20:21:43 EDT 2009


On Sat, Oct 31, 2009 at 18:29 -0500, Peng Yu wrote:
> On Sat, Oct 31, 2009 at 5:45 PM, Wolodja Wentland
> <wentland at cl.uni-heidelberg.de> wrote:
> > On Sat, Oct 31, 2009 at 16:53 -0500, Peng Yu wrote:

> > Are you serious? Do you *really* put each function in its own file? How
> > exactly does this enhance the readability of the source code? Especially
> > if you compare that to a (sic!) modularisation scheme that groups
> > classes and functions together by task or semantic relatedness.

> If two functions are too long to put in file, I generally put them in
> two different files. 

If it should ever happen that two functions are too long to put in a
single file you should refactor your code. It is usually a good idea of
breaking problems down into single steps (ie functions) so you never end
up with a 5000 SLOC *function*.

How do functions of this length enhance the readability of your source
code?

> And I always put a single class in a file.

Why? What do you gain by that?

> Suppose that I have many functions in one file, it is not clear to see
> how many functions are in the file at first glance.

Use a better editor/IDE for that.

[snip]

I thought about answering your post in greater detail, but i would like
to evaluate your style of work first. Is there any place where I can
have a look at some of your source code? It would be perfect if it is a
medium sized project with said unit tests, packages and
function-modules and the rest you described.

Why does not a single module in in the stdlib follow your code layout
scheme?

regards

    Wolodja
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 853 bytes
Desc: Digital signature
URL: <http://mail.python.org/pipermail/python-list/attachments/20091101/a614a05f/attachment.sig>


More information about the Python-list mailing list