Introducing Regular Expressions – Finding your perfect match…in strings – #bookreview

Introducing Regular Expressions
Michael Fitzgerald
(O’Reilly, paperbackKindle)

“Regular expressions are specially encoded text strings used as patterns for matching sets of strings,” Michael Fitzgerald writes in this example-rich new book that focuses on learning by doing.

Veteran programmers who work with Perl, Java, JavaScript, C# and a number of Unix utilities often consider regular expressions to be an important part of their toolkit. Ruby 1.9 and Python 3 also support regular expressions.

“Regular expressions have a reputation for being gnarly,” Fitzgerald notes. However, using the online Regexpal JavaScript regular expression tester, he shows you how to dive right into the very basics and start working your way up.

He introduces several other applications that let you work with regular expressions. And his chapters smoothly take you from matching single digits to matching text strings, number strings, boundaries such as the beginnings or endings of words, character classes, and beyond, including white-space patterns and Unicode. He also shows how to perform some fairly esoteric operations such as “negative lookaheads,” where you verify that a certain pattern of text or digits does not appear in a string ahead of certain other text, numbers, or other qualifiers.

The 136-page book has ten chapters:

  1. What Is a Regular Expression?
  2. Simple Pattern Matching
  3. Boundaries
  4. Alternation, Groups, and Backreferences
  5. Character Classes
  6. Matching Unicode and Other Characters
  7. Quantifiers
  8. Lookarounds
  9. Marking Up a Document with HTML
  10. The End of the Beginning

An appendix provides a regular expression reference, listing such items as control characters, Unicode whitespace characters, metacharacters, and others. There is also a glossary of regular expression terms, such as “greedy match” and “zero-width assertions.”

Fitzgerald recommends his book for those who are “new to regular expressions or programming…the reader who has heard of regular expressions and is interested in them but who really doesn’t understand them yet.”

Those who are a bit beyond the beginner level, however, likewise can benefit from Introducing Regular Expressions and its handy examples and how-to summaries.

Si Dunn

PayPal APIs: Up and Running – How to monetize your apps – #programming #bookreview #in

PayPal APIs: Up and Running, 2nd Edition
Matthew A. Russell
(O’Reilly,
paperback, list price $29.99; Kindle edition, list price $23.99)

The focus of this book is “monetizing your application with payment flows.” That’s a high-toned way of saying Click here to spend some money or Click here to pay your bill or Click here to donate.

PayPal APIs: Up and Running, 2nd Edition shows how to work with PayPal’s platform, which “offers a vast number of API-based products that allow you to monetize your ideas as seamlessly as possible.” (APIs are application programming interfaces.) The book is written clearly and is well illustrated with diagrams, code examples, screen shots and tables.

According to the author, PayPal’s Name-Value Pair (NVP) Application Programming Interfaces (APIs) make it “simple to integrate payments into your applications.  As the merchant, your web application constructs an NVP string and transmit(s) it via HTTPS (HTTP Secure) to the PayPal authorization server, and PayPal sends back an NVP-formatted response that your web application parses for the information relevant to the payment.”

What Matthew A. Russell’s book does not do is “provide complete or exhaustive documentation on all of PayPal’s products or even provide very specific direction on handling some of the most common idiosyncrasies that you might encounter.” But it does “aim to present some of the most popular products in fully integrated realistic scenarios with sample project code that you can study and adapt for your particular needs.” It shows you how to get started and points you toward sources of more advanced information.

Rather than introduce a new, “distinct sample application” in each chapter, the author’s approach is to use a single, simple application “as a foundation,” and “customize it in various ways according to the content of each chapter….” And the chapters are structured to be mostly standalone.

Early in the opening chapter, the foundation application is built using Python and Google App Engine (GAE). And you begin working with PayPal’s APIs.

The 135-page book is organized as follows:

  • Chapter 1: PayPal API Overview
  • Chapter 2: Express Checkout (Including Mobile Express Checkout)
  • Chapter 3: Express Checkout for Digital Goods
  • Chapter 4: Adaptive Payments (Simple, Parallel, and Chained Payments)
  • Chapter 5: Website Payments Pro (Direct Payment)
  • Chapter 6: Instant Payment Notifications (IPNs)
  • Appendix A: Overview of Tweet Relevance - Tweet Relevance is the book’s sample application, “implemented in Python (one of the easiest-to-read programming languages), runs on Google App Engine (a web application platform that is mature and extremely well documented), and munges data from Twitter (an accessible and extremely rich source of information),” Russell writes.
  • Appendix B: Mobile Payment Libraries (MPLs) – Goes beyond the scope of this book. Contains brief information on PayPal’s MPLs, including creating “in-app purchases for iOS, Android, and BlackBerry,” and gives guidance for finding more information.

Each chapter also contains recommended exercises, and the book’s code examples are available online.

The first edition of PayPal APIs: Up and Running was written by Michael Balderas. PayPal APIs: Up and Running, 2nd Edition builds upon his foundation and covers some new aspects and products of PayPal.

If you are a programmer who wants to accept payments for goods or services through PayPal or help a client accept online payments or donations, you should consider getting this useful and well-focused book.

– Si Dunn

#

Think Complexity – Exploring Complexity Science with Python – #programming #bookreview

Think Complexity
By Allen B. Downey
(O’Reilly, paperback, list price $29.99)

Are you a reasonably competent Python programmer yearning for new mental challenges? Allen B. Downey’s Think Complexity definitely can deliver some. His well-written new book can help you dive into complexity science and improve your Python skills at the same time.

Right away, you will see that Think Complexity is not just another how-to-program-in-Python book.

“This book,” Downey states, “is about data structures and algorithms, intermediate programming in Python, computational modeling, and the philosophy of science.” Hello, new world.

His new work, he adds, sprang out of a blending of “boredom and fascination: boredom with the usual presentation of data structures and algorithms and fascination with complex systems. The problem with data structures is that they are often taught without a motivating context; the problem with complexity science is that it usually is not taught at all.”

Complexity science is the scientific study of complex systems – which can be anything from computer networks to the human brain, global markets, ecosystems, metropolitan areas, space shuttles, ant trails, and countless other “systems.”

Complexity science is practiced “at the intersection of mathematics, computer science, and natural science,” Downey says.

How does “the philosophy of science” fit in? Downey’s book offers “experiments and results [that] raise questions relevant to the philosophy of science, including the nature of scientific laws, theory choice, realism and instrumentalism, holism and reductionism, and epistemology.”

Think Complexity “picks up where Think Python left off” and is intended to appeal to the “broad intellectual curiosity” of software engineers and their “drive to expand their knowledge and skills.”

There are case studies, exercises, code samples and even mini-lessons within the exercises. One brief example: “Hoisting is a way to speed up code by moving an expression that does not change out of a loop.” (Hoisting then is applied in a discussion involving Fast Fourier Transform and the Danielson-Lanczos Lemma.)

Not every exercise has an answer against which you can check your work. So you probably shouldn’t jump into this book just now unless you feel confident you are an intermediate-level Python programmer and you are open to wide-ranging mental challenges.

Python, by the way, is a free download available in 2.X and 3.X versions. And, along with Think Python, several other books can help you advance from novice to Python professional.

Head First Python by Paul Barry is a fun, “brain-friendly guide” nicely tailored for beginners who want to advance from “What’s Python?” to understanding how to use the language in real-world applications. The book is written for 3.X versions. And it uses multiple learning methods (often in amusing ways) to help impart the necessary how-to information.

Once you gain a basic understanding of Python, Mark Lutz’s book Learning Python is recommended as the next step. His 4th edition covers both the 2.6 and 3.X versions. If you are a complete Python beginner, you might want to put this book second on your list, rather than dive into it from a cold start. It has 39 chapters and 1162 pages, and it weighs nearly four pounds – which can make it seem a very intimidating starting point. Still, it is a well-written, self-paced tutorial, and it can help you advance to intermediate-level Python programmer and beyond.

Students at Olin College (where Allen B. Downey is a computer science professor) wrote the case studies for Think Complexity. (They were edited by Downey and his wife and reviewed by other Olin faculty members). Appendix A of Downey’s new book contains a call for readers to submit additional case studies.

“Reports that meet the criteria [explained in the appendix] will be published in an online supplement to this book, and the best of them will be included in future print editions.”

This may be an offer – and a Python challenge — you can’t refuse.

#

Si Dunn is a novelist, screenwriter, freelance book reviewer, and former software technical writer and software/hardware QA test specialist. He also is a former newspaper and magazine photojournalist. His latest book is Dark Signals, a Vietnam War memoir available now in paperback. He is the author of a detective novel, Erwin’s Law, a novella, Jump, and several other books and short stories.