You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The PEP is still draft, but I think WPS can implement before adoption. Even if the PEP is rejected I think this is a good idea.
Required specifying "encoding" to open. Even if it's just None.
Thesis
Not specifying the encoding could be considered a bug. Making the effort to choose which encoding is better. At the moment there is no builtin "locale" so we have to settle for None or call locale.getpreferredencoding() all the time. The second option is a bit clumbersome.
## Wrongwithopen('filename.txt') asfd:
fd.read()
## Correctwithopen('filename.txt', encoding='ascii') asfd:
fd.read()
withopen('filename.txt', encoding='utf8') asfd:
fd.read()
# Unfortunately we have to settle for "None" to indicate "locale".withopen('filename.txt', encoding=None) asfd:
fd.read()
Reasoning
Everything described in the PEP.
The text was updated successfully, but these errors were encountered:
Rule request
Inspired by https://www.python.org/dev/peps/pep-0597
The PEP is still draft, but I think WPS can implement before adoption. Even if the PEP is rejected I think this is a good idea.
Required specifying "encoding" to
open
. Even if it's justNone
.Thesis
Not specifying the encoding could be considered a bug. Making the effort to choose which encoding is better. At the moment there is no builtin "locale" so we have to settle for
None
or calllocale.getpreferredencoding()
all the time. The second option is a bit clumbersome.Reasoning
Everything described in the PEP.
The text was updated successfully, but these errors were encountered: