Why doesn't Python's logging module follow PEP8 conventions?


BorageX:

This is just a curiosity for historical purposes:

I'm wondering if anyone knows why the very widely used (and core module) logging doesn't follow Python's PEP-8 naming convention .

For example, in

>>> import logging
>>> log = logging.getLogger("hello")

I wish it was get_logger, but it isn't.

Regarding function names , the PEP8 standard states:

MixedCase is only allowed in contexts that are already mainstream style (e.g. threading.py), to maintain backward compatibility.

Is that so? If so, does loggingit also have to maintain backward compatibility? Or is it just the developers who loggingfeel the use of camelCase?

Of course, the module is well documented and isn't a big deal at all . I'm just curious.

Martijn Pieters:

This loggingmodule was developed by another company in 2001 and is largely based on Log4j. As such, it follows the naming convention chosen by the original author, which is similar to what Log4j chose. The latter also has getLogger()methods .

It wasn't until a year later that PEP 282 proposed to add it to the standard library, by which time the naming convention was fixed.

This package is a known issue , but it's not the only one violating the PEP. From the linked wiki:

PEP8 says - Consistency with this style guide is important. Consistency within a project is more important. Consistency within a module or function is most important.

  • This is true, but cannot be changed due to backward compatibility. may be recording. -techtonik
    • The priority is now lower unless there are proactive measures to ensure that the rest of stdlib is PEP8 compliant. -Vinay Sajip

Last but not least, the style guide itself says the following when applying the style guide:

Stupid Consistency Is Small Minded Leprechaun

Style guides are about consistency. Consistency with this style guide is important. Consistency within a project is more important. Consistency within a module or function is most important.

But most importantly: know when to be inconsistent - sometimes style guides just don't apply. When in doubt, use your best judgment. Check out other examples and decide what works best. Don't hesitate to ask!

In particular: don't break backwards compatibility in order to comply with this PEP!

"Fixing" loggingwill break backwards compatibility and it's not worth it.

Related


Why doesn't Python's logging module follow PEP8 conventions?

BorageX: This is just a curiosity for historical purposes: I'm wondering if anyone knows why the very widely used (and core module) logging doesn't follow Python's PEP-8 naming convention . For example, in >>> import logging >>> log = logging.getLogger("hello"

Why doesn't Python's logging module follow PEP8 conventions?

BorageX: This is just a curiosity for historical purposes: I'm wondering if anyone knows why the very widely used (and core module) logging doesn't follow Python's PEP-8 naming convention . For example, in >>> import logging >>> log = logging.getLogger("hello"

Python PEP8 conventions

username I'm a Python beginner and I read the pep standard that you have to follow when programming in python http://legacy.python.org/dev/peps/pep-0008 Now I have a question. As they mentioned, don't put spaces around the equals sign when using keyword parame

Why doesn't Array#keep_if follow Ruby conventions?

Sharvy Ahmed There is a Ruby convention for naming methods with bang( !) . The convention is selfthat we use bang to let others know about self-modifying behavior if the method changes. For example , wo Array#selectn't change self, but Array#select!will . But

Why doesn't Array#keep_if follow Ruby conventions?

Sharvy Ahmed There is a Ruby convention for naming methods with bang( !) . The convention is selfthat we use bang to let others know about self-modifying behavior if the method changes. For example , wo Array#selectn't change self, but Array#select!will . But

Why Object.hashCode() doesn't follow Java code conventions

cookies Is there any specific reason why hashCode is the only public method of the Object class which doesn't follow Sun's suggested Java code conventions and later Oracle's Java code conventions? I mean can they name it toHashCode() or getHashCode() or create

Why doesn't Array#keep_if follow Ruby conventions?

Sharvy Ahmed There is a Ruby convention for naming methods with bang( !) . The convention is selfthat we use bang to let others know about self-modifying behavior if the method changes. For example , wo Array#selectn't change self, but Array#select!will . But

Why Object.hashCode() doesn't follow Java code conventions

cookies Is there any specific reason why hashCode, the only public method of the Object class, doesn't follow Sun's suggested Java code conventions and later Oracle's Java code conventions? I mean can they name it toHashCode() or getHashCode() or createHashCod

Why Object.hashCode() doesn't follow Java code conventions

cookies Is there any specific reason why hashCode is the only public method of the Object class which doesn't follow Sun's suggested Java code conventions and later Oracle's Java code conventions? I mean can they name it toHashCode() or getHashCode() or create

Why doesn't Array#keep_if follow Ruby conventions?

Sharvy Ahmed There is a Ruby convention for naming methods with bang( !) . The convention is selfthat we use bang to let others know about self-modifying behavior if the method changes. For example , wo Array#selectn't change self, but Array#select!will . But

Why Android conventions don't follow regular Java

Necronomicon: So I've been working on android for about 2 years and Java for 6 years and from the beginning I liked where I found them at Java Convetion , a guide that helped me write more understandable code , you know that the upper layer of a typical Calmel

Why Android conventions don't follow regular Java

Necronomicon: So I've been working on android for about 2 years and Java for 6 years and from the beginning I liked where I found them at Java Convetion , a guide that helped me write more understandable code , you know that the upper layer of a typical Calmel

The logging module doesn't work with Python3

Jonathan I'm having trouble using the standard logging module. If I open the python2.7 shell and import logging everything works fine: $ python >>> import logging >>> However, if I open the python3.4 shell and import logging, I get the following error: $ pyth

The logging module doesn't work with Python3

Jonathan I'm having trouble using the standard logging module. If I open the python2.7 shell and import logging everything works fine: $ python >>> import logging >>> However, if I open the python3.4 shell and import logging, I get the following error: $ pyth