All code in one file

After requesting the organization of my Python project , and then calling it from the parent file in Python , it happens to me that it will be much easier to put all my code in one file (the data will be read from the outside).

I always thought that this is a poor organization of the project, but it seems to be the easiest way to deal with the problems that I think about. I just got the wrong end of the stick with the number of files, or have I seen any great guide in large (for me) projects?

+5
source share
6 answers

If you plan to use any SCM then you will be screwed. Having one file is a guaranteed way to have many collisions and merges that will be painstaking to handle time.

Follow conventions and tear files. If not more than saving a guy who will one day have to support your code ...

+12
source

If your code will work all the time anyway and will not be useful separately, there is nothing wrong with storing everything in one file. I can come up with at least a popular package (BeautifulSoup) that does this. Undoubtedly simplifies installation.

, , , , -.

, , , . . - , .

+4

, . , , . , - . .

+2

, , , - .

, script, .. . , - , , SCM .

, , - /​​. , , .

+2

Python , , .

  • , . , .

    [ , , . Python , .]

  • , . , .

( ) . . . .

, ( ) - ( .

( ) . - . - , .

+2

, , . , , .

, :

  • .

  • .

  • Add unit tests for a new separate file.

  • Recheck the entire project.

Depending on the size of your project, it should not take too many iterations so that you can achieve something reasonable.

+2
source

All Articles