« * K @lernerpython.com

Reuven M. Lerner @lernerpython.com

2026-12-01 16:30 UTC

Want the files in a directory? You could use #Python's os.listdir, but it returns strings. Better to use pathlib's iterdir: from pathlib import Path p = Path('/etc/') type(p.iterdir()) # generator for fn in p.iterdir(): if fn.is_file(): # a path! print(fn, end=' ')

1 picture (not shown on this phone)

2 likes, 0 reposts, 0 replies

3 Next post4 More from @lernerpython.comBackBluesky home
☆ Save to home · 0 Home · Find · Games · Chat · AI · Setup