latin- but may contain files with arbitrarily encoded names from cross-machine copiesthe weband so on depending upon contextexception handlers may be used to suppress some types of encoding errors as well we'll see an example of how this can matter in the first section of where an undecodable directory name generates an error if printed during full disk scan (although that specific error seems more related to printing than to decoding in generalnote that the basic open built-in function allows the name of the file being opened to be passed as either unicode str or raw bytestoothough this is used only to name the file initiallythe additional mode argument determines whether the file' content is handled in text or binary modes passing byte string filename allows you to name files with arbitrarily encoded names unicode policiesfile content versus file names in factit' important to keep in mind that there are two different unicode concepts related to filesthe encoding of file content and the encoding of file name python provides your platform' defaults for these settings in two different attributeson windows import sys sys getdefaultencoding('utf- sys getfilesystemencoding('mbcsfile content encodingplatform default file name encodingplatform scheme these settings allow you to be explicit when needed--the content encoding is used when data is read and written to the fileand the name encoding is used when dealing with names prior to transferring data in additionusing bytes for file name tools may work around incompatibilities with the underlying file system' schemeand opening files in binary mode can suppress unicode decoding errors for content as we've seenthoughopening text files in binary mode may also mean that the raw and still-encoded text will not match search strings as expectedsearch strings must also be byte strings encoded per specific and possibly incompatible encoding scheme in factthis approach essentially mimics the behavior of text files in python xand underscores why elevating unicode in is generally desirable--such text files sometimes may appear to work even though they probably shouldn' on the other handopening text in binary mode to suppress unicode content decoding and avoid decoding errors might still be useful if you do not wish to skip undecodable files and content is largely irrelevant file and directory tools