I am quite confused with the output with the following codes, where I wanted to initialize the 10 range clusters with random numbers. However, the results are all the same.
import random
class range_cluster:
def __init__(self,ranges=[]):
self.ranges = ranges
def generate_range_cluster(nclusters):
range_clusters = [range_cluster() for _ in xrange(nclusters)]
for rc in range_clusters:
rc.ranges.append([random.random(),random.random()])
return range_clusters
def main():
nclusters = 10
range_clusters = generate_range_cluster(nclusters)
for rc in range_clusters:
print rc.ranges[0][0],rc.ranges[0][1]
main()
results:
0.60436009302 0.361964915468
0.60436009302 0.361964915468
0.60436009302 0.361964915468
0.60436009302 0.361964915468
0.60436009302 0.361964915468
0.60436009302 0.361964915468
0.60436009302 0.361964915468
0.60436009302 0.361964915468
0.60436009302 0.361964915468
0.60436009302 0.361964915468