.iterdir() yields immediate children of a directory.
.glob(pattern) finds entries matching a shell-style pattern.
Use "**/*.ext" in glob for recursive searches.
course_parent = Path("..")
print("Immediate children:")
for i, child in enumerate(course_parent.iterdir()):
print(f" {child.name} - {child.is_dir()}")
if i >= 4: break
print("Python files recursively:")
for i, child in enumerate(course_parent.glob("**/*.ipynb")):
print(f" {child}")
if i >= 10: break
Reading and Writing Files with Path
.write_text() and .read_text() handle simple text I/O.
Use p.open(mode="a") for more control (e.g., appending, binary mode).
FoldFold allExpandExpand allAre you sure you want to delete this link?Are you sure you want to delete this tag?
The personal, minimalist, super-fast, database free, bookmarking service by the Shaarli community