Skip to content

Opening files without closing them. #2

Description

@guettli

I often use this:

content=open(file_name).read()

According to your page "python improvements" this should be avoided, since the file does not get closed explicitly.

I don't understand it, since I think the open file gets closed as soon as the variable gets garbage collected.

What do you think? Is above line clean code?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions