Should I create each class in its own .py file?

前端 未结 6 1405
故里飘歌
故里飘歌 2020-12-18 18:01

I\'m quite new to Python in general.

I\'m aware that I can create multiple classes in the same .py file, but I\'m wondering if I should create each class in its own

6条回答
  •  旧时难觅i
    2020-12-18 18:29

    Each .py file represents a module, so you should keep logical groups of functions, constants and classes together in the same file.

    Each class in a .py file will just create epic bloat in your module table, since if you're only interested in one class you can still

    from whatever import SomeClass
    

提交回复
热议问题