summaryrefslogtreecommitdiffstats
path: root/src/s3select/example/expr_genrator.py
blob: 0d21fcee6e39e63026dfdf72ef5a241f5cf634a0 (plain)
1
2
3
4
5
6
7
8
9
import random
import sys

def expr(depth):
    if depth==1 or random.random()<1.0/(2**depth-1): 
        return str(int(random.random() * 100) + 1)+".0"
    return '(' + expr(depth-1) + random.choice(['+','-','*','/']) + expr(depth-1) + ')'

print expr( int(sys.argv[1]) )