Hello World! – Updated book brings new fun to learning Python – #programming #bookreview

Sande--Hello World!, 2e

Hello World!

Computer Programming for Kids and Other Beginners (2nd Edition)

Warren Sande and Carter Sande

(Manning, paperback)

Many politicians, educators and pundits keep arguing over whether the United States should offer computer programming classes to all students in kindergarten through 12th grade.

Others say all of us, including senior citizens, should do some coding to help us (1) maintain mental sharpness and good computer skills and (2) ward off late-in-life memory problems such as dementia.

These contentious debates are a long way from being settled, of course. Meanwhile, questions also rage over which programming languages we should learn. There are, after all, many dozens now in use.

Experienced software developers often state that Python is a good choice for youngsters ready to tackle their first “real” language, particularly once they have spent some time mastering Scratch, which MIT describes as “a programming language and an online community where children can program and share interactive media such as stories, games, and animation with people from all over the world.”

Manning Publications recently has brought out an updated second edition of its popular Python how-to book, Hello World!, written by Warren Sande and his son Carter Sande.

Some parents want to hand a programming book over to a child and let them learn at their own pace. And that can be done, in many cases, with Hello World! (It is written at a 12-year-old’s reading level, according to Manning). But other parents want to share the learning experience and be mentors, too, and the Sande book can be used effectively that way, as well. In either case, many children younger than 12 also should be able to learn from it.

Be sure to note the “Other Beginners” in the book’s subtitle. I have taken classes in Python, and I have worked my way through a couple of  Python programming books. Hello World! is proving a useful addition to my library, too, because it gives some clear explanations and examples for  many different concepts, such as using variable nested loops, importing portions of modules, or providing collision detection in a game, to name just a few.

One big question quickly pops up when someone decides to learn to program in Python: Python 2 or Python 3?

Several years ago, the language was updated from version 2 to version 3, but many users of version 2 chose to not upgrade. So now we recently have had Python 2.7.6 and Python 3.3.3 (with Python 3.4 coming soon). The two versions have some similarities, but they also have essential differences. Bottom line: They do not play well together.

In this second edition of Hello World!, the authors have elected to stick with Python 2 in their text and code examples. But they have added notes to help make the code work for students using Python 3. Likewise, they have added an appendix explaining some major differences between Python 2 and Python 3.

Other significant changes include using color in illustrations and code listings and, in the chapter on GUI programming, using PyQT, rather than the no-longer-supported PythonCard. And the updated book now spans more than 460 pages, including its index.

With Hello World!, even the most eager student who is a very fast reader can be kept focused and busy for many hours while learning how to program in Python.

Si Dunn

Python Cookbook, 3rd Edition – Breaking Away from Python 2 to Python 3 – #programming #bookreview

Python Cookbook, 3rd Edition
David Beazley & Brian K. Jones
(O’Reilly – paperback, Kindle)

PYTHON 3 users will be very pleased with this new book. Those who still cling to Python 2 likely will not.

Even though “most working Python programmers continue to use Python 2 in production,” its authors concede, and “Python 3 is not backward compatible with past versions,” this third edition of the popular Python Cookbook is intended to be used only with Python 3.3 and above.

“Just as Python 3 is about the future, this edition…represents a major change over past editions,” Beazley and Jones state. “First and foremost, this is meant to be a very forward looking book. All of the recipes have been written and tested with Python 3.3 without regard to past Python versions or the ‘old way’ of doing things. In fact, many of the recipes will only work with Python 3.3 and above.”

THEIR “ultimate goal,” they point out, was “to write a book of recipes based on the most modern tools and idioms possible. It is hoped that the recipes can serve as a guide for people writing new code in Python 3 or those who hope to modernize existing code.”

The 687-page Python Cookbook, 3rd Edition is not intended for beginning programmers. However, beginners can learn a few things from it and keep the book on their shelves for future use as they gain experience with Python 3.

And, it can be a helpful guide if you are working to update some Python 2 code to Python 3. According to the authors, “many of the recipes aim to illustrate features that are new to Python 3 and more likely to be unknown to even experienced programmers using older versions.”

THE book offers 15 chapters of how-to recipes organized into the following major categories:

  1. Data Structures and Algorithms
  2. Strings and Text
  3. Numbers, Dates, and Times
  4. Iterators and Generators
  5. Files and I/O
  6. Data Encoding and Processing
  7. Functions
  8. Classes and Objects
  9. Metaprogramming
  10. Modules and Packages
  11. Network and Web Programming
  12. Concurrency
  13. Utility Scripting and Administration
  14. Testing, Debugging, and Exceptions
  15. C Extensions

Each of the approximately 260 recipes is presented using a “problem-solution-discussion” format. Here are a few recipe titles chosen at random:

  • “Combining and Concatenating Strings”
  • “Reformatting Text to a Fixed Number of Columns”
  • “Bypassing Filename Encoding”
  • “Iterating over the Index-Value Pairs of a Sequence”
  • “Capturing Variables in Anonymous Functions”
  • “Implementing Stateful Objects or State Machines”
  • “Enforcing an Argument Signature on *args and **kwargs”
  • “Creating Custom Exceptions”
  • “Writing a Simple C Extension Module”

SOME of the book’s code examples are complete. But others, the authors caution, “are often just skeletons that provide essential information for getting started, but which require the reader to do more research to fill in the details.”

If you are serious about Python and keeping pace with its progress, you should seriously consider getting this excellent how-to book.

Si Dunn

Make something new, with MakerBot or Raspberry Pi – #bookreview #programming #diy

O’Reilly has released two new books to help you get started with two hot new products: the MakerBot desktop 3D printer and the Raspberry Pi, a tiny, inexpensive computer the size of a credit card.

Here are short reviews of the two how-to guides:

Getting Started with MakerBot
Bre Pettis, Anna Kaziunas France & Jay Shergill
(O’Reilly –
paperback, Kindle)

The MakerBot 3D printer has captured worldwide attention for its ability to replicate objects such as game pieces, knobs and other plastic parts no longer available from manufacturers, and its use also to produce small art works.

“In our consumer-focused, disposable world, a MakerBot is a revitalizing force for all your broken things,” the authors state. (One of them, Bre Pettis, is one of MakerBot’s creators.)

The MakerBot machine, however, also can be a revitalizing force for artistic endeavors and, in some cases, dreams of self-employment. It is, after all, essentially a small factory in a box.

Getting Started with MakerBot introduces the machine and things you can make with it from your own designs or from designs downloaded from the web. “Though the underlying engineering principles behind a MakerBot are quite complex, in a nutshell, a MakerBot is a very precise, robotic hot glue gun mounted to a very precise, robotic positioning system,” the three writers point out.

In 213 pages, the book covers the basics, from history to set-up, and then shows you how to “print 10 useful objects right away.” It also introduces how to design your own 3D objects, using SketchUp, Autodesk 123D, OpenSCAD, and some other tools.

Getting Started with MakerBot is well-written, heavily illustrated, and organized to help you advance from unboxing a MakerBot to turning out products and creations and becoming a significant citizen of the “Thingiverse”—where “one must share designs…but all are welcome to reap the bounty of shared digital designs for physical objects.”


Getting Started with Raspberry Pi
Matt Richardson & Shawn Wallace
O’Reilly –
paperback, Kindle)

The Raspberry Pi “is meant as an educational tool to encourage kids to experiment with computers.” But many adults are latching to the tiny device as well, because it comes preloaded with interpreters and compilers for several programming languages, including Python, Scratch, C, Ruby, Java, and Perl. Its operating system is Linux Raspbian.

The Raspberry Pi is not plug-and-play, but it can be connected to – and control –a number of electronic devices. And the list of uses  for the microcomputer keeps growing.

Some owners have made their Raspberry Pi devices into game machines. Others have connected many of the units together to create low-budget supercomputers. Some are using them as web servers. And still others work at the  “bare metal” of a Raspberry Pi to create and test new operating systems. Intriguing new roles for the Raspberry Pi keep appearing, and the surge will continue as more adults and kids start working with the tiny but powerful device.

Getting Started with Raspberry Pi covers the basics of hooking up, programming and running the device. It also provides several starter projects, including how to use a Raspberry Pi as a web server or in other roles.

Once you know what you’re doing, “You can even create your own JSON API for an electronics project!” the authors promise.

The well-written book packs a lot of how-to information into its 160 pages, including working at the command line in Linux, learning to program the device, and creating simple games in Python and Scratch.

— Si Dunn

Python for Kids – A fun & efficient how-to book that even grownups can enjoy – #programming #bookreview

Python for Kids
Jason R. Briggs
(No Starch Press – paperback, Kindle)

Subtitled “A Playful Introduction to Programming,” Python for Kids is recommended “for kids aged 10+ (and their parents).”

But what if your kids are grown or you don’t have any kids? Should you ignore this book while learning Python? Absolutely not.

I’ve recently taken two Python 3 classes, and I wish I had had many of the explanations and illustrations in Python for Kids available to help me grasp some of the concepts. I’m keeping this book handy on my shelf for quick reference, right next to works such as Head First Python and Think Python.

Yeah, it contains plenty of silliness for kids, such as a wizard’s shopping list that includes “bear burp” and “slug butter,” and using if and elif statements to create jokes such as “What did the green grape say to the blue grape? Breathe! Breathe!” (I have grandchildren who consider this stuff uproariously funny.)

But Python for Kids also covers a lot of serious topics in its 316 pages and shows—simply and clearly—how to handle many major and minor aspects of the Python programming language. NOTE: This book is for the newer 3.X versions of Python, not older 2.X versions that are still in use and still a focus of some books for beginners.

One Python class I took didn’t introduce tuples until the 7th week of lectures. Python for Kids, however, has the reader using tuples on page 38, right after six pages of learning how to work with strings and lists. And the explanations and examples for these elements are clearer than what I got in a college-level course. (Of course, it helps when exercises involve “bear burp” and “gorilla belly-button lint” rather than boring generics such as “Mary has 3 oranges” and “Jack has 6 pencils.”)

Jason R. Brigg’s new book also shows how to draw shapes and patterns and create simple games and animations—topics not covered in some other beginning Python books I have used.

Another cool feature of this excellent how-to book is an afterword titled “Where to Go from Here.” It provides suggestions and gives links for those who want to learn more about games and graphics programming or take up other programming languages such as Ruby, PHP or JavaScript.

Bottom line, Python for Kids offers education and entertainment for children, their parents, and almost anyone else serious about having some fun while learning Python 3.

Si Dunn

Big Data Book Blast: Hadoop, Hive…and Python??? – #programming #bookreview

Big Data is hothotHOT. And O’Reilly recently has added three new books of potential interest to Big Data workers, as well as those hoping to join their ranks.

Hadoop, Hive and–surprise!—Python are just a few of the hot tools you may encounter in the rapidly expanding sea of data now being gathered, explored, stored, and manipulated by companies, organizations, institutions, governments, and individuals around the planet. Here are the books:

Hadoop Operations
Eric Sammer
(O’Reilly, paperbackKindle)

“Companies are storing more data from more sources in more formats than ever before,” writes Eric Sammer, a Hadoop expert who is principal solution architect at Cloudera. But gathering and stockpiling data is only “one half of the equation,” he adds. “Processing that data to produce information is fundamental to the daily operations of every modern business.”

Enter Apache Hadoop, a “pragmatic, cost-effective, scalable infrastructure” that increasingly is being used to develop Big Data applications for storing and processing information.

“Made up of a distributed filesystem called the Hadoop Distributed Filesystem (HDFS) and a computation layer that implements a processing paradigm called MapReduce, Hadoop is an open source, batch data processing system for enormous amounts of data. We live in a flawed world, and Hadoop is designed to survive in it by not only tolerating hardware and software failures, but also treating them as first-class conditions that happen regularly.”

Sammer adds: “Hadoop uses a cluster of plain old commodity servers with no specialized hardware or network infrastructure to form a single, logical, storage and compute platform, or cluster, that can be shared by multiple individuals or groups. Computation in Hadoop MapReduce is performed in parallel, automatically, with a simple abstraction for developers that obviates complex synchronization and network programming. Unlike many other distributed data processing systems, Hadoop runs the user-provided processing logic on the machine where the data lives rather than dragging the data across the network; a huge win for performance.”

Sammer’s new, 282-page book is well written and focuses on running Hadoop in production, including planning its use, installing it, configuring the system and providing ongoing maintenance. He also shows “what works, as demonstrated in crucial deployments.”

If you’re new to Hadoop or still getting a handle on it, you need Hadoop Operations. And even if you’re now an “old” hand at Hadoop, you likely can learn new things from this book. “It’s an extremely exciting time to get into Apache Hadoop,” Sammer states.

Programming Hive
Eric Capriolo, Dean Wampler, and Jason Rutherglen
(O’Reilly, paperback Kindle)

“Hive,” the three authors point out, “provides an SQL dialect, called Hive Query Language (abbreviated HiveQL or just HQL), for querying data stored in a Hadoop cluster.”

They add: “Hive is most suited for data warehouse applications, where relatively static data is analyzed, fast response times are not required, and when data is not changing rapidly.”

Their well-structured and well-written book shows how to install and test Hadoop and Hive on a personal workstation – “a convenient way to learn and experiment with Hadoop.” Then it shows “how to configure Hive for use on Hadoop clusters.”

They also provide a brief overview of Hadoop and MapReduce before diving into Hive’s command-line interface (CLI) and introductory aspects such as how to embed lines of comments in Hive v0.80 and later.

From there, the book flows smoothly into HiveQL and how to use its SQL dialect to query, summarize, and analyze large datasets that Hadoop has stored in its distributed filesystem.

User documentation for Hive and Hadoop has been sparse, so Programming Hive definitely fills a solid need. Significantly, the final chapter presents several “Case Study Examples from the User Trenches” where real companies explain how they have used Hive to solve some very challenging problems involving Big Data.

Python for Data Analysis
Wes McKinney
(O’Reilly, paperbackKindle)

No, Python is not the first language many people think of when picturing large data analysis projects. For one thing, it’s an interpreted language, so Python code runs a lot slower than code written in compiled programming languages such as C++ or Java.

Also, the author concedes, “Python is not an ideal language for highly concurrent, multithreaded applications, particularly applications with many CPU-bound threads.” The software’s global interpreter lock (GIL) “prevents the interpreter from executing more than one Python bytecode instruction at a time.”

Thus, Python will not soon be challenging Hadoop to a Big Data petabyte speed duel.

On the other hand, Python is reasonably easy to learn, and it has strong and widespread support within the scientific and academic communities, where a lot of data must get crunched at a reasonable clip, if not at blinding speed.

And Wes McKinney is the main author of pandas, Python’s increasingly popular open source library for data analysis. It (pandas) is “designed to make working with structured data fast, easy, and expressive.”

His book makes a good case for using Python in at least some Big Data situations. “In recent years,” he states, “Python’s improved library support (primarily pandas) has made it a strong alternative for data manipulation tasks. Combined with Python’s strength in general purpose programming, it is an excellent choice as a single language for building data-centric applications.”

Much of this well-written, well-illustrated book “focuses on high-performance array-based computing tools for working with large data sets.” It uses a case-study-examples approach to demonstrate how to tackle a wide range of data analysis problems, using Python libraries that include pandas, NumPy, matplotlib, and IPython, “the component in the standard scientific Python toolset that ties everything together.”

By the way, if you have never programmed in Python, check out the end of McKinney’s book. An appendix titled “Python Language Essentials” gives a good overview of the language, with a specific bias toward “processing and manipulating structured and unstructured data.”

If you do scientific, academic, or business computing and need to crunch and visualize a lot of data, definitely check out Python for Data Analysis.

You may be pleasantly surprised at how well and how easily Python and its data-analysis libraries can do the job.

Si Dunn

Practical Computer Vision with SimpleCV – ‘Seeing’ with Python – #programming #bookreview

Practical Computer Vision with SimpleCV
Kurt Demaagd, Anthony Oliver, Nathan Oostendorp, and Katherine Scott
(O’Reilly, paperbackKindle)

SimpleCV, or Simple Computer Vision, is “an easy-to-use Python framework that bundles together open source computer vision libraries and algorithms for solving problems,” according to the authors of this useful and informative how-to book.

The subtitle is “Making Computers See in Python,” and the codes examples require Python 2.7.

Why learn computer vision? “As cameras are becoming standard PC hardware and a required feature of mobile devices, computer vision is moving from a niche tool to an increasingly common tool for a diverse range of applications,” the authors note.

Indeed, cameras and computer vision now are being used in everything from facial recognition systems and video games to automobile safety, industrial automation, medicine, planetary exploration, and even agriculture.

“The SimpleCV framework has compiled installers for Windows, Mac, and Ubuntu Linux, but it can be used on any system on which Python and OpenCV can be built,” the authors state.

Practical Computer Vision with SimpleCV shows how to use the framework and simple application examples to get started toward building your own computer vision applications. The 240-page book has 10 chapters:

  • Introduction
  • Getting to Know the SimpleCV Framework
  • Image Sources
  • Pixels and Images
  • The Impact of Light
  • Image Arithmetic
  • Drawing on Images
  • Basic Feature Detection
  • FeatureSet Manipulation
  • Advanced Features (focuses on optical flow)

The book also has three appendices: Advanced Shell Tips, Cameras and Lenses; and Advanced Features (deals with advanced segmentation and feature extraction tools).

Practical Computer Vision with SimpleCV provides a good overview of computer vision basics and shows, using simple but effective examples, how you can put them to work.

Si Dunn

Think Python – A gentle and effective guide to learning Python programming – #programming #bookreview

Think Python
Allen B. Downey
(O’Reilly, paperbackKindle)

First, a confession. My favorite book for learning Python is Head First Python by Paul Barry. It literally does throw you head-first into Python programming. By page 10, it has you working with nested lists. By page 30, you are creating a function that you will save and turn into a module just a few pages later. By the time you hit page 50, you have learned how to upload code to PyPi. And, as the book continues, you keep improving and expanding the functionality of one project that stays in development from chapter to chapter.

That said, I hereby declare that Think Python by Allen B. Downey is my new co-favorite book for learning Python.  I intend to keep it handy right alongside Head First Python.

Just about anyone studying or using Python can benefit from having Think Python on their bookshelf, in their computer, on their mobile device or, better yet, accessible in all these places. It is an excellent reference book, as well as a clear, concise and calm how-to guide for beginning programmers.

Think Python takes a gentle yet effective approach to introducing and exploring the language one step at a time. First you learn some basic programming concepts. Then, 13 pages in, you start easing into the language at the level of “Hello, World!”, plus variables, expressions, and statements.

The 277-page book has 19 chapters that carefully explain and illustrate each key point, without overkill. The author is a veteran instructor of computer languages, and he also is the author of a well-known book that has been around since 1999, in one form or another: How to Think Like a Computer Scientist.

Think Python is an outgrowth of the Python version that book. Downey has added materials on debugging and other topics, plus some exercises and case studies. And he has gotten plenty of proofreading help from more than 100 enthusiastic followers of his writings and teaching.

What I like most about Think Python are its short, concise, clear explanations of each new concept and its use of very short code examples. When I’m in the mood to spend just a few minutes reviewing or learning a new concept in Python, I can open Think Python and quickly find a refresher or a new area to try out. Head First Python, on the other hand, suits me best when I have an hour or two to stay focused on reading, keying in a lot more code and making the required changes to the ongoing project.

One minor caution: There are differences – sometimes significant and sometimes merely irritating – between Python 3 and Python 2. Head First Python focuses on Python 3 code and Think Python uses Python 2 code examples. But Think Python’s author has been careful to minimize the conflict and explains what to do when using Python 3.

The main thing to remember is that the print statement in Python 2 has become print(), a function, in Python 3. So if, for example, the book’s code says print ‘Hello, World!’ and you are using Python 3, you type print(‘Hello, World!’), instead.

It’s not hard. But the opportunity to print or print() something does come up a lot in the text.

Si Dunn