Loading video player…

Welcome to the Boiler Log Digest

This course shows you how JavaScript programs import modules, take command-line arguments, and work with files. Imports, arguments and files all have JavaScript counterparts, but a few of the differences fail quietly.

Your project is a school site manager’s Python tool for the weekly boiler log, and you’ll port it to JavaScript. Here’s a first taste. The Python script takes the log’s name and the limit from the command line, and prints both. These are its first lines:

Language: Python
import sys

def main():
    path = sys.argv[1]
    threshold = float(sys.argv[2])

    print(f"Checking {path} against {threshold}")

if __name__ == "__main__":
    main()

Run as python digest.py logs/week-44.log 75, it prints this:

Language: Program Output
Checking logs/week-44.log against 75.0

Here’s the line-by-line JavaScript port of those lines, digest.js:

Language: JavaScript
const path = process.argv[1];
const threshold = Number(process.argv[2]);

console.log(`Checking ${path} against ${threshold}`);

Run the same way with node digest.js logs/week-44.log 75, it logs this, with no error:

Language: Program Output
Checking /home/dev/boiler-digest/digest.js against NaN

Instead of the log’s name, you get the script’s own path, and the limit is NaN: not a number. The path depends on where the script is on your system, and on Windows it starts with C:\. You’ll see where both come from.

That site manager is Dev. Every Friday, the heating contractor wants the boiler’s peak flow temperature and every reading over 75 °C. The school’s new dashboard runs on JavaScript, so you’ll port his tool.

By the end of this course, you’ll be able to:

  • Import from your own modules, and choose what each one shares
  • Run a module as a script that reads command-line arguments
  • Read and write files
  • Port the whole boiler log digest to JavaScript

You only need to know how to write Python scripts that import your own modules, read sys.argv, and open files. In JavaScript, you only need to know how to write a small program with functions, arrays, objects, for...of loops, and array destructuring.

A current version of Node.js and of Python is fine: the examples use Node 26 and Python 3.15.

The course mixes short videos and text lessons, with exercises where you write the code yourself. Every video has a summary below it. A project puts the digest together, and a quiz and a summary close the course.

Next up: Importing From Your Own Files, a video.

Download

Sample Code (.zip)

15.0 KB
Download

Course Slides (.pdf)

731.0 KB

00:00 Welcome to JavaScript Modules and Scripts for Pythonistas! This course shows you how JavaScript programs import modules, take arguments, and work with files.

00:11 Your project is a school site manager’s Python tool for the weekly boiler log, which flags every reading over a temperature limit, and you’ll port it to JavaScript.

00:21 Here’s a first taste.

00:24 The site manager runs his script with the week’s log and the limit, and Python prints both. Here’s the JavaScript port of those lines. Run the same way, it logs this, with no error.

00:39 Instead of the log’s name, you get the script’s own path. And the limit is NaN: not a number. You’ll see where both come from. Imports, arguments and files all have JavaScript counterparts, but a few differences fail quietly.

00:58 That site manager is Dev. Every Friday, the heating contractor wants the boiler’s peak flow temperature and every reading over 75 degrees. The school’s new dashboard runs on JavaScript, so you’ll port his tool.

01:14 By the end, you’ll import from your own modules, run a script with arguments, read and write files, and port the whole tool.

01:23 You only need to know Python scripts with imports, sys.argv and files, and basic JavaScript: functions, arrays, objects and loops.

01:35 Short videos mix with text lessons and exercises, and every video has a summary below it. A project, a quiz and a summary close the course. Next up is Importing From Your Own Files, which opens on Dev’s two files.

Become a Member to join the conversation.