Skip to content

Instantly share code, notes, and snippets.

@thanatos
Created July 14, 2017 16:53
Show Gist options
  • Save thanatos/16ea55d29e68db925fbae448ef4f90c1 to your computer and use it in GitHub Desktop.
Save thanatos/16ea55d29e68db925fbae448ef4f90c1 to your computer and use it in GitHub Desktop.
Python bugs I see all the time

Failure to close resources

Don't:

fobj = open('myfile.txt')
# tons of code
fobj.close()

"tons of code" will inevitably fail, at which point, the file descriptor is leaked, and left to be cleaned up by the GC. It is poor form to say "Python is refcounted": Python the language is not reference counted, it is garbage collected.

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