temporary files temporary files it then creates temporaryfile object and prints its name and mode (the default mode is binary but for this example we have overwritten this so that plain text is usedwe have then written line to the file using seek we are repositioning ourselves at the start of the file and then reading the line we have just written import tempfile print('tempfile gettempdir():'tempfile gettempdir()temp tempfile temporaryfile(' +'print('temp name:'temp nameprint('temp mode:'temp modetemp write('hello world!'temp seek( line temp readline(print('line:'linethe output from this when run on an apple mac istempfile gettempdir()/var/folders/ / nrnt pn ypg dq gn/ temp name temp modewlinehello worldnote that the file name is ' and that the temporary directory is not meaningful name working with paths the pathlib module provides set of classes representing filesystem pathsthat is paths through the hierarchy of directories and files within an operating systems file structure it was introduced in python the core class in this module is the path class path object is useful because it provides operations that allow you to manipulate and manage the path to file or directory the path class also replicates some of the operations available from the os module (such as mkdirrename and rmdirwhich means that it is not necessary to work directly with the os module path object is created using the path constructor functionthis function actually returns specific type of path depending on the type of operating system being used such as windowspath or posixpath (for unix style systems