Programming Python, 2nd Edition
Programming Python focuses on advanced uses of the Pythonprogramming/scripting language, which has evolved from an emerginglanguage of interest primarily to pioneers, to a widely acceptedtool that traditional programmers use for real day-to-daydevelopment tasks. With Python, you can do almost anything you cando with C++; but Python is an interpreted language designed forrapid application development and deployment. Among other things,Python supports object-oriented programming; a remarkably simple,readable, and maintainable syntax; integration with C components;and a vast collection of pre-coded interfaces and utilities. AsPython has grown to embrace developers on a number of differentplatforms (Unix, Linux, Windows, Mac), companies have taken noticeand are adopting Python for their products. It has shown upanimating the latest Star Wars movie, serving up maps anddirectories on the Internet, guiding users through Linuxinstallations, testing chips and boards, managing Internetdiscussion forums, scripting online games, and even scriptingwireless products. Programming Python is the mostcomprehensive resource for advanced Python programmers availabletoday. Reviewed and endorsed by Python creator Guido van Rossum,who also provides the foreword, this book zeroes in on real-worldPython applications. It's been updated for Python 2.0 and coversInternet scripting, systems programming, Tkinter GUIs, Cintegration domains, and new Python tools and applications. Amongthem: IDLE, JYthon, Active Scripting and COM extensions, Zope, PSPserver pages, restricted execution mode, the HTMLgen and SWIG codegenerators, thread support, CGI and Internet protocol modules. Suchapplications are the heart and soul of this second edition. VeteranO'Reilly author Mark Lutz has included a platform-neutral CD-ROMwith book examples and various Python-related packages, includingthe full Python 2.0 source code distribution.
Programming Python, 2nd Edition
Think Python is an introduction to Python programming for beginners. It starts with basic concepts of programming; it is carefully designed to define all terms when they are first used and to develop each new concept in a logical progression. Larger pieces, like recursion and object-oriented programming, are divided into a sequence of smaller steps and introduced over the course of several chapters.
"The best part of programming is the triumph of seeing the machine do something useful. Automate the Boring Stuff with Python frames all of programming as these small triumphs; it makes the boring fun." - Hilary Mason, Data Scientist and Founder of Fast Forward Labs
In Automate the Boring Stuff with Python, you'll learn how to use Python to write programs that do in minutes what would take you hours to do by hand - no prior programming experience required. Once you've mastered the basics of programming, you'll create Python programs that effortlessly perform useful and impressive feats of automation to:
Al Sweigart is a software developer and teaches programming to kids and adults. He has written several books for beginners and makes them freely available at InventWithPython.com. His personal website is AlSweigart.com. You can follow @AlSweigart on Twitter and Twitch.
Less than five years ago, I wrote the foreword for the 1st edition of ProgrammingPython. Since then, the book has changed about as much as thelanguage and the Python community! I no longer feel the need todefend Python: the statistics and developments listed in Mark'sPreface speak for themselves.In the past year, Python has made great strides. We released Python2.0, a big step forward, with new standard library features such asUnicode and XML support, and several new syntactic constructs,including augmented assignment: you can now write x += 1 instead of x= x+1. A few people wondered what the big deal was (answer: insteadof x, imagine dict[key] or list[index]), but overall this was a bighit with those users who were already used to augmented assignment inother languages.Less warm was the welcome for the extended print statement:print>>file, a shortcut for printing to a different file objectthan standard output. Personally, it's the Python 2.0 feature I usemost frequently, but most people who opened their mouth about found itan abomination. The discussion thread on the newsgroup berating thissimple language extension was one of the longest ever -- apart fromthe never-ending Python vs. Perl thread.Which brings me to the next topic. (No, not Python vs. Perl. Thereare better places to pick a fight than a foreword.) I mean the speedof Python's evolution, a topic dear to the heart of the author of thisbook. Every time I add a feature to Python, another patch of Mark'shair turns grey: there goes another chapter out of date! Especiallythe slew of new features added to Python 2.0, which appeared just ashe was working on this second edition, made him worry: what if Python2.1 added as many new things? The book would be out of date as soonas it was published!Relax, Mark. Python will continue to evolve, but I promise that Iwon't remove things that are in active use! For example, there was alot of worry about the string module. Now that string objects havemethods, the string module is mostly redundant. I wish I could todeclare it obsolete (or deprecated) to encourage Python programmers tostart using string methods instead. But given that a large majorityof existing Python code -- even many standard library modules --imports the string module, this change is obviously not going tohappen overnight. The first likely opportunity to remove the stringmodule will be at the introduction of Python 3000; and even then therewill probably be a string module in the backwards compatibilitylibrary for use with old code.Python 3000?! Yes, that's the nickname for the next generation of thePython interpreter. The name may be considered a pun on Windows 2000,or a reference to Mystery Science Theatre 3000, a suitably Pythonesquetv show with a cult following. When will Python 3000 be released?Not for a loooooong time -- although you won't quite have to waituntil the year 3000.Originally, Python 3000 was intended to be a complete rewrite andredesign of the language. It would allow me to make incompatiblechanges in order to fix problems with the language design that weren'tsolvable in a backwards compatible way. The current plan, however, isthat the necessary changes will be introduced gradually into thecurrent Python 2.x line of development, with a clear transition paththat includes a period of backwards compatibility support.Take for example integer division. In line with C, Python currentlydefines x/y with two integer arguments to have an integer result. Inother words, 1/2 yields 0! While most died-in-the-wool programmersexpect this, it's a continuing source of confusion for newbies, whomake up an ever-larger fraction of the -- exponentially growing --Python user population. From a numerical perspective, it really makesmore sense for the / operator to yield the same value regardless ofthe type of the operands: after all, that's what all other numericoperators do. But we can't simply change Python so that 1/2 yield0.5, because (like removing the string module) it would break too muchexisting code. What to do?The solution, too complex to describe here in detail, will have tospan several Python releases, and involves gradually increasingpressure on Python programmers (first through documentation, thenthrough deprecation warnings, and eventually through errors) to changetheir code. By the way, a framework for issuing warnings will beintroduced as part of Python 2.1. Sorry, Mark!So, don't expect the announcement of the release of Python 3000 anytime soon. Instead, one day you may find that you are _already_ usingPython 3000 -- only it won't be called that, but rather something likePython 2.8.7. And most of what you've learned in this book will stillapply! Still, in the mean time references to Python 3000 will abound;just know that this is intentionally vaporware in the purest sense ofthe word. Rather than worry about Python 3000, continue to use andlearn more about the Python version that you do have.I'd like to say a few words about Python's current development model.Until early 2000, there were hundreds of contributors to Python, butessentially all contributions had to go through my inbox. To proposea change to Python, you would mail me a context diff, which I wouldapply to my work version of Python, and if I liked it, I would checkit into my CVS source tree. (CVS is a source code version managementsystem, and the subject of several books.) Bug reports followed thesame path, except I also ended up having to come up with the patch.Clearly, with the increasing number of contributions, my inbox becamea bottleneck. What to do?Fortunately, Python wasn't the only open source project with thisproblem, and a few smart people at VA Linux came up with a solution:SourceForge! This is a dynamic website with a complete set ofdistributed project management tools available: a public CVSrepository, mailing lists (using Mailman, a very popular Pythonapplication!), discussion forums, bug and patch managers, and adownload area, all made available to any open source project for theasking.We currently have a development group with SourceForge checkinprivileges of 30 volunteers, and a development mailing list comprisingtwice as many folks. The privileged volunteers have all sworn theirallegiance to the BDFL (Benevolent Dictator For Life -- that's me :-).Introduction of major new features is regulated via a lightweightsystem of proposals and feedback, Python Enhancement Proposals (PEPs).Our PEP system proved so succesful that it was copied almost verbatimby the Tcl community when they made a similar transition fromCathedral to Bazaar.So, it is with confidence in Python's future that I give the floor toMark Lutz. Excellent job, Mark. And to finish with my favorite MontyPython quote: Take it away, Eric, the orchestra leader!Guido van RossumReston, Virginia, January 2001 Tweets by @ThePSF !function(d,s,id)var js,fjs=d.getElementsByTagName(s),p=/^http:/.test(d.location)?'http':'https';if(!d.getElementById(id))js=d.createElement(s);js.id=id;js.src=p+"://platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);(document,"script","twitter-wjs"); The PSFThe Python Software Foundation is the organization behind Python. Become a member of the PSF and help advance the software and our mission. 041b061a72