Are classes in Python in different files?

前端 未结 2 1352
挽巷
挽巷 2021-02-01 13:43

Much like Java (or php), I\'m use to seperating the classes to files.
Is it the same deal in Python? plus, how should I name the file?
Lowercase like classname.py or t

2条回答
  •  花落未央
    2021-02-01 14:23

    No, you can define multiple classes (and functions, etc.) in a single file. A file is also called a module.

    To use the classes/functions defined in the module/file, you will need to import the module/file.

提交回复
热议问题