Define Classes in Packages

后端 未结 3 1587
醉酒成梦
醉酒成梦 2021-02-20 02:57

I\'m learning Python and I have been playing around with packages. I wanted to know the best way to define classes in packages. It seems that the only way to define classes in a

3条回答
  •  谎友^
    谎友^ (楼主)
    2021-02-20 03:52

    In Python you're not restricted to defining 1 class per file and few do that. You can if you want to though - it's totally up to you. A Package in Python is just a directory with an

    __init__.py 
    

    file. You don't have to put anything in that file you can to control what gets imported etc.

提交回复
热议问题