Efficient_Python_tricks_and_tools_for_data_scientists icon indicating copy to clipboard operation
Efficient_Python_tricks_and_tools_for_data_scientists copied to clipboard

Issue on page /Chapter2/pathlib.html

Open alustig3 opened this issue 2 years ago • 0 comments

the pathlib example seems odd/incorrect, returning 12?

to make it similar to the os example perhaps it should be the following?

from pathlib import Path

# Create a new directory
folder = Path("new")
folder.mkdir(exist_ok=True)

# Create new file inside new directory
file = folder / "new_file.txt"

# Write text
file.write_text("Hello World!")

# Read text
print(file.read_text())

with a result of:

Hello World!

alustig3 avatar Dec 09 '23 23:12 alustig3