file and directory handling shutil the shutil module is used to perform high-level file operations such as copyingremovingand renaming the functions in this module should only be used for proper files and directories in particularthey do not work for special kinds of files on the file system such as named pipesblock devicesetc alsobe aware that these functions don' always correctly deal with advanced kinds of file metadata ( resource forkscreator codesetc copy(src,dstcopies the file src to the file or directory dstretaining file permissions src and dst are strings copy (srcdstlike copy(but also copies the last access and modification times copyfile(srcdstcopies the contents of src to dst src and dst are strings copyfileobj( [length]copies all data from open file object to open file object length specifies maximum buffer size to use negative length will attempt to copy the data entirely with one operation (that isall data will be read as single chunk and then writtencopymode(srcdstcopies the permission bits from src to dst copystat(srcdstcopies the permission bitslast access timeand last modification time from src to dst the contentsownerand group of dst are unchanged copytree(srcdstsymlinks [,ignore]]recursively copies an entire directory tree rooted at src the destination directory dst will be created (and should not already existindividual files are copied using copy (if symlinks is truesymbolic links in the source tree are represented as symbolic links in the new tree if symlinks is false or omittedthe contents of linked files are copied to the new directory tree ignore is an optional function that can be used to filter out specific files as inputthis function should accept directory name and list of directory contents as return valueit should return list of filenames to be ignored if errors occur during the copy processthey are collected and the error exception is raised at the end of processing the exception argument is list of tuples containing (srcnamedstnameexceptionfor all errors that occurred ignore_pattern(pattern pattern creates function that can be used for ignoring all of the glob-style patterns given in pattern pattern etc the returned function accepts as input two argumentsthe first of which is directory name and the second of which is list of directory contents as resulta list of filenames to be ignored is returned the primary use of the returned function is as the ignore parameter to the copytree(function shown earlier howeverthe resulting function might also be used for operations involving the os walk(function lib fl ff