The Elements of Python Style
Most of it is pretty obvious. However, what I am still fighting myself on with Python is a project layout&#x2F;module structure.<p>In languages with C++-like OOP model (Java, PHP) it&#x27;s most of the time reasonable to settle on &quot;1 file, 1 class&quot; and to use directory structure the same way you use namespaces. Actually, in some such languages it&#x27;s enforced.<p>For PHP it still leaves a problem with where you shoud put&#x2F;expect to find anything beside classes, but it&#x27;s fine, more or less. I hope some day we&#x27;ll decide even more generally what works best, but for now it&#x27;s decided per project&#x2F;framework and it&#x27;s mostly bearable.<p>For Ruby it&#x27;s mostly the same as for PHP, even though the language is a bit more flexible. But it&#x27;s still normal to use class as the main entity, so pretty much the same guidelines&#x2F;problems apply.<p>For Python… I cannot decide yet, and what&#x27;s worse, looking at the code on, say, Github, it doesn&#x27;t seem like it&#x27;s less of a problem for many others. Because some of &quot;solutions&quot; are seriously horrible. No project structure whatsoever, tens of classes in the same file. Classes, functions and even app-specific code (like GUI, CLI or HTTP-routing) all in the same file. Multi-thousand LOC files are considered completely normal. Ridiculous amount of code in __init__.py, that completely re-arranges submodule structure or even defines a bunch of new code. Hell, I&#x27;ve seen projects (more than 1) almost entirely written in the __init__.py! Please don&#x27;t say you think it&#x27;s normal.<p>I would say that things remind of &quot;project-structure&quot; in C, but (it&#x27;s scary to suddenly realize that) it would actually be a compliment for Python, because even though large files are considered normal as well, with modern practices of writing C-code and all that &quot;C-lang OOP&quot; model stuff it&#x27;s mostly clear where you should put something. With Python I&#x27;m never sure. The only way to find something is to use grep.<p>With things like that in Python, it&#x27;s even no use to speak of a &quot;project structure&quot; in the more general sense, aside from what&#x27;s enforced by the frameworks like Django.<p>So, any suggestions?