Skip to Content
193 results
0 likes
Finding Files in Python With pathlib glob and rglob Level: Intermediate

glob() searches one folder, rglob() searches every folder below it. Neither sorts the results, skips folders like .venv, or matches .CSV on Linux. Add those yourself, and always do a dry run before deleting anything.

0 likes
pip freeze vs Writing requirements.txt by Hand: Which One to Use Level: Intermediate

pip freeze gives exact versions but hides what you chose. A hand-written file shows what you chose but isn't exact. For anything you deploy, keep both: one file for intent, one frozen for exact versions.

0 likes
Diagnose pytest Discovery and src-Layout Import Errors Level: Intermediate

Separate zero collected tests from an import failure, install into the correct environment, and prove the selected test catches a broken assertion.

0 likes
Reading a Large Text File in Python Line by Line Level: Intermediate

for line in file reads one line at a time, so a 10 GB file uses almost no memory. read() and readlines() load everything. Count, filter and stop early without building a list, and read in blocks when there are no lines.

0 likes
Speeding Up Many Downloads in Python With ThreadPoolExecutor Level: Advanced

Downloads spend most of their time waiting. ThreadPoolExecutor lets many waits overlap: 20 half-second downloads in 2 seconds instead of 10. Handle failures with as_completed, pick a sensible worker count and respect the server.

0 likes
Python Type Conversion: Why "5" + 5 Fails and How to Fix It Level: Beginner

Python refuses to guess whether "5" + 5 means 55 or 10. Convert with int(), float() and str() where values come in, handle text that won't convert, and avoid the bool("False") trap.

0 likes
Python while Loops: Keep Asking Until the Input Is Valid Level: Beginner

People type the wrong thing, sometimes more than once. A while True loop with try/except, a range check and a way out keeps asking until the answer is usable, so the rest of your code never has to check again.

0 likes
Writing Your Own Python Context Manager, With a Class or contextlib Level: Advanced

Write a context manager when something must be undone no matter how the block ends. Build one as a class and with @contextmanager, keep yield inside try/finally, and don't swallow errors by accident.

0 likes
Make a Button Do Something With addEventListener Level: Beginner

Find the button, attach a listener, change something on the page when it's clicked. Three steps, and two mistakes that make it silently do nothing.

0 likes
JavaScript Arrays in 15 Minutes Level: Beginner

Arrays hold lists: cart items, names, scores. Create them, read them, add and remove items, find things, and copy them without changing the original by accident.

0 likes
Arrow Functions in 10 Minutes Level: Beginner

Arrow functions are a shorter way to write a function, and they are everywhere in modern JavaScript. Learn the short forms, the object-return trap, and the one place you shouldn't use them.

0 likes
Debugging With console.log Without Drowning in Output Level: Beginner

console.log is the fastest way to see what your code is doing, until it prints 300 lines and you can't find the one that matters. Label your logs, log objects properly, use console.table and console.group, and clean up before you ship.