Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use with open instead of manually opening and closing file handler #53

Open
Tadaboody opened this issue Jan 1, 2019 · 0 comments
Open
Labels
new This issue hasn't been looked at yet smell A new smell to report and fix

Comments

@Tadaboody
Copy link
Owner

New smell

Smelly code

fp = open(path,args,kwargs)
# Body
fp.close

Fixed code

with open(path,args,kwargs as fp:
    # Body

Why is it smelly?

Without a context manager you need to manually close the file, which is eror-prone.

@Tadaboody Tadaboody added smell A new smell to report and fix new This issue hasn't been looked at yet labels Jan 1, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
new This issue hasn't been looked at yet smell A new smell to report and fix
Projects
None yet
Development

No branches or pull requests

1 participant