[Python] Is it PEP8 compliant to import CamelCase as lowercase?

Discussão em 'Python' iniciado por Stack, Julho 30, 2025.

  1. Stack

    Stack Membro Participativo

    According to PEP8 modules should be lowercase. Some popular ones out there (e.g. Gtk) however follow the CamelCase convention.

    In order to have a pythonic codebase and mitigate spillage of this policy breach it seems like the following is a clean way to deal with this:

    import CamelcasedModule as camelcased_module


    Linters such as pep8-naming however claim that such practice violates PEP8 and throw an N813 error.

    As I failed to find any direct passage in PEP8 addressing this I was wondering which way to go in order to stay true to the zen of python.

    Sitenote: Previously this question mentioned Gtk as an example:

    from gi.repository import Gtk as gtk


    Which was misleading as Gtk is a class not a module and as such does not apply to the question. For transparency and because the answers to this may still be usefull it is mentioned here.

    Continue reading...

Compartilhe esta Página