Skip to content

Opening files without closing them. #2

@guettli

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?

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