« * K @lernerpython.com

Reuven M. Lerner @lernerpython.com

2026-11-30 16:30 UTC

Using Pathlib in #Python means both files and directories are PosixPath objects (on my Mac): fp = Path('/etc/passwd') dp = Path('/Users/reuven/') Use is_file/is_dir methods to distinguish: fp.is_file() #True fp.is_dir() #False dp.is_file() #False dp.is_dir() #True

1 picture (not shown on this phone)

2 likes, 0 reposts, 1 replies

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