materials icon indicating copy to clipboard operation
materials copied to clipboard

Add example using 'with' statement and urlopen

Open njneered opened this issue 7 months ago • 0 comments

This pull request adds a beginner-friendly Python example to demonstrate the use of the with statement with urllib.request.urlopen() for safely opening and reading a URL. This addresses Issue #423.

The example is located in: context-managers/urlopen-example/with_urlopen_example.py

It includes a simple script that fetches content from https://www.python.org and prints the first 200 bytes. The code also contains helpful comments for learners.

njneered avatar Jun 03 '25 20:06 njneered