My use case: I have a component that parses a bunch of files in a directory, and provides progress feedback with "." (dots), for every file that is read. Instead of sprinkling print(".", end=""), I wanted to wire this up with the logging module, so that I can get the fine grained configuration that logging provides (eg. in production, I want to hide the progress dots, without adding branching logic to my code). The problem here is that the logging module by default, emits a newline after each logging statement, which would make the output ugly, because I want this:

Parsing 5 files:
..... OK

Instead of:

Parsing 5 files:
.
.
.
.
.
OK

So at first look, there are two ways of making this work:

logging.py
python
import logging
import sys

# Solution 1, programmatically:

logger = logging.getLogger(__name__)
handler = logging.StreamHandler(sys.stdout)
handler.terminator = ''

# Solution 2, if you want to use the DSL, write a wrapper class:

def my_handler(*args, **kwargs):
    handler = logging.StreamHandler(*args, **kwargs)
    handler.terminator = ''
    return handler

logging.config.dictConfig({
    # ...
    'handlers': {
        'console': {
            '()': my_handler,
        }
    }
    # ...
})

But there is actually a way to do this only using the DSL. There is an undocumented "." property (the dot here is a coincidence with my usecase), that allows you to set arbitrary attributes on handlers, so you can do this:

python
logging.config.dictConfig({
    # ...
    'handlers': {
        'console': {
            'class': logging.StreamHandler
            '.': {
                'terminator': ''
            }
        }
    }
    # ...
})

I can find absolutely no mention of this "." property anywhere, in the official python docs. I googled around for a solution, and I stumbled across a bug report that lead me to a commit on CPython. Basically, everything you set under ".", gets setattributed on the handlers. Interestingly enough, there is another "magic" (albeit documented) key for loggers, called "()", which let you specify constructor args for external handlers that do not follow the same constructor signature as the standard library ones (the standard library ones only accept a stream).

The more you know