Import order question
Steven D'Aprano
steve at pearwood.info
Wed Feb 19 02:32:02 EST 2014
On Tue, 18 Feb 2014 13:44:47 -0800, Rick Johnson wrote:
> Are you telling me you're willing to search through a single file
> containing 3,734 lines of code (yes, Tkinter) looking for a method named
> "destroy" of a class named "OptionMenu" (of which three other classes
> contain a method of the same exact name!), when all you needed to do was
> open one single module named "tk_optionmenu.py" and do a single search
> for "def destroy"?
How do you know that the module tk_optionmenu.py contains the class
OptionMenu? Perhaps it contains the function optionmenu. Or the class
TK_OptionMenu.
For a mere 4000 lines of code, yes, I'd rather have it all in the one
file, presuming that they are all related pieces of code. Much, much,
much easier to search, edit and maintain; avoids circular imports and
other dependency problems.
If there are parts of that module that stand alone, then arguably they
ought to be extracted out into a separate module. But other than that,
4000 lines of code isn't so big that we should be splitting the file
apart merely for the size.
[...]
> But even if this were not an API, breaking large chunks of code up and
> spreading them across individual files is the key to managing code
> bases.
You left out the word "badly".
--
Steven
More information about the Python-list
mailing list