On Wednesday, June 13, 2018 at 4:27:35 AM UTC-5, Chris Angelico wrote: > It's more his definition of "large" and "small" that I was > disagreeing with. You're absolutely right that a dense > global scope is a problem; but a "one class per file" rule > is a terrible idea.
What if the "one class" spans thousands of lines? Surely you don't believe that class definitions (outside of toy classes and academic examples, that is) are limited to a couple dozen lines, do you? > A hundred tiny files is far harder to work with than ten > medium-sized files, I doubt anyone here is suggesting that modules should be limited to 10 lines each, or something ridiculous like that. Heck, the minimum class definition _alone_ (at least, if you're going to properly utilize vertical whitespace) requires around 2 dozen lines. ## BEGIN MODULE ## 01# 02# import something here 03# 04# define constants here 05# 06# 07# (WHITE SPACE BUFFER) 08# 09# 10class MyClass(object): 11 def __init__(self): 12 pass 13 14 def method(self): 15 pass 16# 17# 18# (WHITE SPACE BUFFER) 19# 20# 21# (INITIALIZATION/TESTING/LOGIC/ETC) 22# 23# ## END MODULE ## That's 23 lines of code to define whitespace and boilerplate _alone_. > and IMO a single file with all the code in it is only > slightly worse. That is to say, I would prefer to work with > a single gigantic file than a directory with lots and lots > of tiny interdependent files, each one importing six or > seven others. Blame the import mess on a missing feature, not on those of us who prefer reasonably sized source files. To alleviate a large portion of the circular import mess (and depending on the coding style employed, possibly all of it), python's packaging system could have leveraged the power of "componentized modules" -- much the way that classes share variables between them using class attributes (no import required!) -- but unfortunately, this powerful feature was overlooked. And packages are nothing more than some kind of quasi directory tree which masquerades itself as a namespace so that a programmer can replace a long import path with a _dot_. WELL, WHOOP-DEE-DO! That's like a superhero without a superpower. Hmm... After considering the blinkered state of Python packages and the resulting pitfalls of the python import mechanism, we can only assume the Python gods found inspiration for this "hot mess" in the title of GnR's fifth studio album. -- https://mail.python.org/mailman/listinfo/python-list