manually closing files this script also goes out of its way to manually close its files as we also saw in we can often get by with single lineopen(partname'wb'write(chunkthis shorter form relies on the fact that the current python implementation automatically closes files for you when file objects are reclaimed ( when they are garbage collectedbecause there are no more references to the file objectin this one-linerthe file object would be reclaimed immediatelybecause the open result is temporary in an expression and is never referenced by longer-lived name similarlythe input file is reclaimed when the split function exits howeverit' not impossible that this automatic-close behavior may go away in the future moreoverthe jython java-based python implementation does not reclaim unreferenced objects as immediately as the standard python you should close manually if you care about the java portyour script may potentially create many files in short amount of timeand it may run on machine that has limit on the number of open files per program because the split function in this module is intended to be general-purpose toolit accommodates such worst-case scenarios also see ' mention of the file context manager and the with statementthis provides an alternative way to guarantee file closes joining files portably back to moving big files around the houseafter downloading big game program fileyou can run the previous splitter script by clicking on its name in windows explorer and typing filenames after splitsimply copy each part file onto its own floppy (or other more modern medium)walk the files to the destination machineand re-create the split output directory on the target computer by copying the part files finallythe script in example - is clicked or otherwise run to put the parts back together example - pp \system\filetools\join py #!/usr/bin/python ""###############################################################################join all part files in dir created by split pyto re-create file this is roughly like 'cat fromdir/tofilecommand on unixbut is more portable and configurableand exports the join operation as reusable function relies on sort order of filenamesmust be same length could extend split/join to pop up tkinter file selectors ###############################################################################""import ossys readsize complete system programs