Cette page n'est pas encore disponible en français, sa traduction est en cours. Si vous avez des questions ou des retours sur notre projet de traduction actuel, n'hésitez pas à nous contacter.
Metadata
ID:python-best-practices/open-add-flag
Language: Python
Severity: Error
Category: Best Practices
Description
If a flag is opened for read-only, no need to put a flag to open the file.
defprint_foo():withopen("myfile.txt","r")asmyfile:# no need to specify the "r" flagcontent=myfile.read()withopen(path,"rb")asf:forchunkiniter(lambda:f.read(4096),b""):hasher.update(chunk)