dotfiles/bin/contract
michener 3b98c350b4 tmux settings
git-svn-id: http://photonzero.com/dotfiles/trunk@48 23f722f6-122a-0410-8cef-c75bd312dd78
2010-03-23 23:09:16 +00:00

34 lines
449 B
Python
Executable file

#!/usr/bin/env python
import sys
loadfile = sys.stdin
if len(sys.argv) == 1:
print "No command to run"
sys.exit(1)
if len(sys.argv) == 3:
if sys.argv[2] != "-":
loadfile = open(sys.argv[2])
def add(x, y):
return x + y
def sub(x, y):
return x - y
def mult(x, y):
return x * y
def div(x,y):
return x / y;
lis = []
for line in loadfile:
if line.strip() <> "":
x = float(line)
lis.append(x)
print reduce(eval(sys.argv[1]), lis)