Elbenfreund Elbenfreund - 1 year ago 63
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


from gi.repository import Gtk as gtk

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

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 Source

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

You can read more about that here.