This post has been de-listed

It is no longer included in search results and normal feeds (front page, hot posts, subreddit posts, etc). It remains visible only via the author's post history.

3
Opening/reading files. %%writefile vs with open method
Post Body

So I’m just starting a beginner python course on Udemy called “2020 complete python Bootcamp: from zero to hero in python”. It’s going great but I want to make sure I’m understanding the difference between two ways of opening and reading txt/CSV files.

The course has me do the whole %%writefile newfile.txt method, but then switches to “with open (“newfile.txt”, mode = “w”) as f:

The second one is described as you don’t need to close the file.

Can’t you create a file with either one? I’m not quite understanding the application differences between the two I guess.

Any help is appreciated!

Author
Account Strength
90%
Account Age
5 years
Verified Email
Yes
Verified Flair
No
Total Karma
1,742
Link Karma
937
Comment Karma
805
Profile updated: 1 day ago
Posts updated: 3 months ago

Subreddit

Post Details

We try to extract some basic information from the post title. This is not always successful or accurate, please use your best judgement and compare these values to the post title and body for confirmation.
Posted
3 years ago