I can't believe it...
20 years of in my fingers and I discover that the “right” way to put a docstring to a variable is “after” the variable.

Why is that? Because Python uses interpretable strings and therefore the variable takes precedence. Just as you'd put a docstring after a function or class declaration, you have to do the same in Python. And that's what makes mkdocstrings-python work!

It's not at all intuitive, but in the long run it's much easier to read!

Suivre

Now let's move on to all the reasons given in PEP 258 (rejected elsewhere).
peps.python.org/pep-0258/

The reasons given are very logical - but so are the reasons for rejection. The thing is, since I've switched to this way of documenting my code, I find it obvious and clever.

The fact that the code editor (neovim) and mkdocstrings follow this logic reinforces my belief that we should all do things this way.

But what do you think?

Inscrivez-vous pour prendre part à la conversation
techlover

Technology lovers, here we are — (development, digital artwork, science…)