How to import only one module in a package when the package __init__.py has already imports the modules?
Steven D'Aprano
steve at REMOVE-THIS-cybersource.com.au
Sat Oct 31 22:42:14 EDT 2009
On Sat, 31 Oct 2009 20:03:29 -0500, Peng Yu wrote:
>> 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*.
>
> My definition of long is more than one screen.
>
>> How do functions of this length enhance the readability of your source
>> code?
>
> If the code is of one screen, you can easily see what it does without
> having to scroll back and forth.
Far enough, but you exchange scrolling back and forth from function to
function with tabbing through editor tabs from file to file. I don't see
that this is an advantage.
You also complicate calling functions. Instead of:
def parrot():
spam()
ham()
cheeseshop()
you need:
from spam import spam
from ham import ham
from import cheeseshop
def parrot():
spam()
ham()
cheeseshop()
This is not an advantage!
--
Steven
More information about the Python-list
mailing list