Let's parse it up with Parsley. Following the standard example of other parsing frameworks, we're going to build a standard mathematical expression parser. Unlike other frameworks like PyParsing, Parsley grammars are defined in a giant string, rather than a special DSL.
Let's start with something that can interpret a collection of digits, and spit out a number:
import parsley