self.__doc__

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.

Example

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!

AND  NOW

FOR SOMETHING

COMPLETELY

DIFFERENT.

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.

The Problem

  • 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!

  • document yourself,
    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, ...
ThomasWaldmann.__doc__

 

ESP32 / MicroPython / ULP

(powerful MicroController)

BorgBackup

(deduplicating Backup Software)

nsupdate.info

(dyndns Service / Software)

MoinMoin Wiki

(Wiki Software)

 

Python / Linux / FOSS

Crypto / Privacy

Name/Nick.__doc__

 

bold/big:

few, relevant

keywords
(in the context of the event)

(below that, maybe some more details or explanations, small font)

 

Optional:
use colours, Home Page, github, ...

 

https://slides.com/ thomaswaldmann/ self-doc

 

License:  WTFPL

Please distribute

self.__doc__ (en)

By Thomas Waldmann

self.__doc__ (en)

  • 1,955