Skip to content

Read The Docs

Technical writing: documentation, READMEs and API references

t/read-the-docs

Technical writing, READMEs, changelogs and API reference. The unglamorous work that decides whether anyone can use your thing.

11 members
2 posts
Created Aug 2026

Community rules

3 rules for t/read-the-docs

  1. Show the before and after

    Doc feedback is only useful next to the text it is about.

  2. Bring the detail

    Versions, error text, what you already tried. "It does not work" is not a question anyone can answer.

  3. No drive-by self promotion

    Share your own work when it answers the thread. A link with no context is a advert, and it gets removed.

Discussions

1
  • Read The Docs

    The main discussion

    Primary

    Nobody has said anything yet. Be the first.

Showing 2 posts.

Posts in t/read-the-docs

8

  • Accepted answer

    Lakshmi, Anitha is right, and you are in good company: this has caught professional programmers for thirty years. Python evaluates a default value once, when the def line runs, not each time the function is called. So there is exactly one list, created when the function was defined, and every call that does not pass marks gets that same list and appends to it. You can show the children the shared list directly. After your three calls: print(add_mark.__defaults__) # ([45, 78, 62],) The usual fix is to use None as the default and make a fresh list inside: def add_mark(mark, marks=None): if marks is None: marks = [] marks.append(mark) return marks For fourteen year olds, try this: the default list is one notebook kept on the teacher's desk. Every student who does not bring their own notebook writes in the desk notebook. By the third student, the page is already full of other people's marks. The fix gives each student a new notebook when they arrive. It is also in the official Python tutorial, in the section on default argument values, with a warning in a box saying the default is evaluated only once. Showing them that box is a nice lesson in itself: the docs knew before we did. Cheers, G.
    1 reply