Elbenfreund Elbenfreund - 6 months ago 14
Python Question

Is it PEP8 compliant to import CamelCase as lowercase?

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 (please note that this is not specific to

Gtk
):

from gi.repository import Gtk as gtk


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.

Answer

Gtk is a class not a module. Class names should use CapWords convention.

You can read more about that here.

Comments