related to database topicsaddressed in in this sectionwe'll take brief tutorial look at the built-in file object and explore handful of more advanced file-related topics as usualyou should consult either python' library manual or reference books such as python pocket reference for further details and methods we don' have space to cover here rememberfor quick interactive helpyou can also run dir(fileon an open file object to see an attributes list that includes methodshelp(filefor general helpand help(file readfor help on specific method such as readthough the file object implementation in provides less information for help than the library manual and other resources the file object model in python just like the string types we noted in file support in python is bit richer than it was in the past as we noted earlierin python str strings always represent unicode text (ascii or wider)and bytes and bytearray strings represent raw binary data python draws similar and related distinction between files containing text and binary datatext files contain unicode text in your scripttext file content is always str string-- sequence of characters (technicallyunicode "code points"text files perform the automatic line-end translations described in this by default and automatically apply unicode encodings to file contentthey encode to and decode from raw binary bytes on transfers to and from the fileaccording to provided or default encoding name encoding is trivial for ascii textbut may be sophisticated in other cases binary files contain raw -bit bytes in your scriptbinary file content is always byte stringusually bytes object-- sequence of small integerswhich supports most str operations and displays as ascii characters whenever possible binary files perform no translations of data when it is transferred to and from filesno lineend translations or unicode encodings are performed in practicetext files are used for all truly text-related dataand binary files store items like packed binary dataimagesaudio filesexecutablesand so on as programmer you distinguish between the two file types in the mode string argument you pass to openadding " ( 'rb''wb'means the file contains binary data for coding new file contentuse normal strings for text ( 'spamor bytes decode()and byte strings for binary ( 'spamor str encode()unless your file scope is limited to ascii textthe text/binary distinction can sometimes impact your code text files create and require str stringsand binary files use byte stringsbecause you cannot freely mix the two string types in expressionsyou must choose file mode carefully many built-in tools we'll use in this book make the choice for usthe struct and pickle modulesfor instancedeal in byte strings in file and directory tools