“Use the Source, Luke”
TheprecedingchapterintroducedPython’sclient-sideInternettoolset—thestan-
dardlibrarymodulesavailableforemail,FTP,networknews,andmore,fromwithin
aPythonscript.Thischapterpicksupwherethelastoneleftoffandpresentsacom-
pleteclient-sideexample—PyMailGUI,aPythonprogramthatsends,receives,com-
poses, and parses Internet email messages.
Althoughtheendresultisaworkingprogramthatyoucanactuallyuseforyour
email,thischapteralsohasafewadditionalagendasworthnotingbeforeweget
started:
Client-side scripting
Foronething,PyMailGUIimplementsafull-featuredGUIthatrunsonyour
machine,andcommunicateswithyourmailserverswhennecessary.Assuch,it
isanetworkclientprogramthatfurtherillustratessomeoftheprecedingchap-
ter’stopics,anditwillhelpuscontrastserver-sidesolutionsintroducedinthe
next chapter.
Code reuse
Additionally,PyMailGUItiestogetheranumberoftheutilitymoduleswe’ve
beenwritinginthebooksofar,anddemonstratesthepowerofcodereuseinthe
process—itusesathreadmoduletoallowmailtransferstooverlapintime,aset
ofmailmodulestoprocessmessagecontentandrouteitacrossnetworks,awin-
dowprotocolmoduletohandleicons,andsoon.Moreover,itinheritsthe
poweroftoolsinthePythonstandardlibrary,suchastheemailpackage;mes-
sage construction and parsing, for example, is trivial here.
Programming in the large
Andfinally,becausePyMailGUIisarelativelylarge-scaleprogram(atleastas
Pythonprogramsgo),itshowsbyexamplesomeofthecodestructuringtech-
niquesthatcomeinhandyonceweleavetherealmofthesmall.Object-oriented
programming(OOP)andmodulardesignworkwellheretodividethesystemin
smaller, self-contained units.