Thomas Waldmann @ EuroPython 2018
__doc__ in Python
Objects can use __doc__ to self-describe themselves.
Pronounciation: "dunder doc" (aka docstring)
You can use it to:
interactively get help
- generate docs (Sphinx and other tools)
- access it from Python -
the Code has access to its own docs.
class OrderedDict: """a key->value mapping that remembers insert order""" ... >>> help(OrderedDict) 'a key->value mapping ...' >>> print(OrderedDict.__doc__)
'a key->value mapping ...'
You don't have to wonder about what it is, it self-documents!
Real Life Doc Issues
Conferences, Hacker Spaces, ...
many (unknown) people,
potentially working on interesting things,
- but: no or little docs!
$people doing $things.
$people2 doing $things2.
everybody doing something - but what?
just chat to them?
you can do that,
but many don't dare.
- and even if:
that does not scale, inefficient for N > 10.
__doc__ to the rescue!
read docs of other people.
Paper, Screen, Projector, Poster, T-Shirt
few, good readable key words
(from 2m distance, while walking by)
- what interests you,
what you love,
what you work on / did work on, ...
https://slides.com/ thomaswaldmann/ self-doc
By Thomas Waldmann