kozec / syncthing-gtk

GTK3 & python based GUI for Syncthing
GNU General Public License v2.0
1.29k stars 140 forks source link

Replace usages of the file() builtin with open() #474

Closed dralley closed 6 years ago

dralley commented 6 years ago

Python 2 documentation recommends against the usage of file(), and Python 3 removes it entirely. open() can do everything file() can do and using it is identical apart from having a few extra features.

Also, it's usually recommended to use the context manager pattern when dealing with files to prevent resource leaks. If you don't close the files, they will stick around in the process' file descriptor table. When using a context manager, the file is closed at the end of the scope.Alternatively the files could just be closed manually but this is easier and cleaner.