python: naming a module that has a two-word name

前端 未结 4 952
执笔经年
执笔经年 2021-01-30 06:36

I\'m trying to put together a really simple module with one .py source file in it, and have already run into a roadblock. I was going to call it scons-config but

4条回答
  •  夕颜
    夕颜 (楼主)
    2021-01-30 06:57

    If you have to, always use underscores _.

    Using a dot . would not even work, otherwise

    from scons.config import whatever
    

    would break.

    But PEP 8 clearly describes it:

    Package and Module Names

    Modules should have short, all-lowercase names. Underscores can be used in the module name if it improves readability. Python packages should also have short, all-lowercase names, although the use of underscores is discouraged.

    UPDATE:

    To directly target your question: I think sconsconfig is fine. It is not too long and quite readable.

    But honestly, I don't think anyone will blame you if you use underscores and your code will run with either decision. There is always a certain level where you should not care that much anymore.

提交回复
热议问题