Fork me on GitHub

One Line Calculator in Python

Rob Crowther just posted on his blog, Dress to Survive, some amazing Python foo that creates a six function calculator in python using some creative regular expression matching and a lambda thrown in for good measure.

>>> print map(...)
5 + 5
3 ^ 2
[10, 9]

I’ll let him divulge all the nitty gritty details. Be sure to check it out at his Web site. He has both the one-liner version and a fully commented version. Pretty darn smart.

You should follow me on Twitter.

blogroll

social