cleanremotes(cfconnuploadall(cfconnnot only is the upload script simpler now because it reuses common codebut it will also inherit any changes made in the download module for instancethe istextkind function was later augmented with code that adds the pyw extension to mimetypes tables (this file type is not recognized by default)because it is shared functionthe change is automatically picked up in the upload programtoo this script and the one it imports achieve the same goals as the originalsbut changing them for easier code maintenance is big deal in the real world of software development the followingfor exampledownloads the site from one server and uploads to anotherc:\pp \internet\ftp\mirrorpython downloadflat_modular py test clean target directory firstpassword for lutz on home rmi netconnecting downloading -longmont-classes html to test\ -longmont-classes html as text lines omitted downloading relo-feb -index html to test\relo-feb -index html as text done files downloaded :\pp \internet\ftp\mirrorpython uploadflat_modular py test clean target directory firstpassword for lutz on learning-python comconnecting uploading test\ -longmont-classes html to -longmont-classes html as text lines omitted uploading test\zopeoutline htm to zopeoutline htm as text done files uploaded refactoring with classes the function-based approach of the last two examples addresses the redundancy issuebut they are perhaps clumsier than they need to be for instancetheir cf configuration options object provides namespace that replaces global variables and breaks crossfile dependencies once we start making objects to model namespacesthoughpython' oop support tends to be more natural structure for our code as one last twistexample - refactors the ftp code one more time in order to leverage python' class feature example - pp \internet\ftp\mirror\ftptools py #!/bin/env python ""#############################################################################use ftp to download or upload all files in single directory from/to remote site and directorythis version has been refactored to use classes and oop for namespace and natural structurewe could also structure this as download superclassand an upload subclass which redefines the clean and transfer methodsbut then there is no easy way for another client to client-side scripting