The open-bugs check in release-note.js has its braces now, so the teammate’s second line runs only when it should. A little further down, the Python script has a branch that does nothing yet: an else holding a single pass and a TODO to link the bug tracker on all-clear days.
That line ports in seconds, and the port runs fine today. In this lesson, you’ll see why it would fail on a later afternoon, write an empty block the way JavaScript expects, and then move the script’s comments and docstring across. Start with the branch that waits.
Write an Empty Block as {}
Python won’t accept an indented block with nothing in it, because indentation needs at least one statement to show where the block is, and a comment doesn’t count. That’s what pass is for. Here’s the part of release_note.py that holds it:
CLIENT = "Fernleaf Bakery"
BUGS_OPENED = 9
BUGS_CLOSED = 7
open_bugs = BUGS_OPENED - BUGS_CLOSED
if open_bugs > 0:
print("Open bugs:", open_bugs)
else:
pass # TODO: link the bug tracker
print("Note ready for", CLIENT)
With nine bugs opened and seven closed, Python prints Open bugs: 2, skips the else, and finishes the note. A line-by-line port keeps the pass and turns the # into //, which comments to the end of the line as # does in Python:
const CLIENT = "Fernleaf Bakery";
const BUGS_OPENED = 9;
const BUGS_CLOSED = 7;
const openBugs = BUGS_OPENED - BUGS_CLOSED;
if (openBugs > 0) {
console.log("Open bugs:", openBugs);
} else {
pass; // TODO: link the bug tracker
}
console.log("Note ready for", CLIENT);
Maya runs it at the end of the day, and the note comes out the same as Python’s:
Open bugs: 2
Note ready for Fernleaf Bakery
Tomorrow, Theo closes the last two bugs and changes one setting before he runs the script. Before reading on, predict what the note says when BUGS_CLOSED is 9: