문제

I am writing a game in Python that has many classes and methods, and I want to know if it is advantageous to store the classes in the main python .py file or store each category of classes in separate files, then import them. This would help with organization, but are there any other pros/cons?

도움이 되었습니까?

해결책

It's my understanding that the result of import is essentially making the compiler jump to that file and parse it in place of the import line. Basically making it like the entire file was pasted into the file doing the importing, at the line where the import happens.

So essentially, it's helpful with organization and sanity. Once a project starts to get large enough, it would be impractical to maintain all the code in a single file.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top