<commit_before>import random

class Dice(object):

    sides = ['red','orange','yellow','green','cray','blue']

    def __init__(self,num):
        self.color = self.sides[num]
        print self.color

    @staticmethod
    def calcSum(color1,color2):
        return Dice.sides.index(color1) + Dice.sides.index(color2) + 2

    @classmethod
    def get_dice(cls):
        return cls(random.randint(0,6))

if __name__ == '__main__':
    d1 = Dice.get_dice()
    d2 = Dice.get_dice()
    print Dice.calcSum(d1.color,d2.color)<commit_msg>make dice into a iterator<commit_after>#coding:utf-8
import random

class Dice(object):

    sides = ['red','orange','yellow','green','cray','blue']

    def __init__(self,num=1,iterend=6):
        print 'init > num:%s | iterend:%s' % (num,iterend)
        self.color = self.sides[num]
        self.iterend = iterend
        print 'init > color: ',self.color

    @staticmethod
    def calcSum(color1,color2):
        return Dice.sides.index(color1) + Dice.sides.index(color2) + 2

    @classmethod
    def get_dice(cls):
        return cls(num=random.randint(0,5)) # randint(a,b) : a <= x <= b

    def __iter__(self):
        self.count = 0
        return self

    def next(self):#shit! in python3, the func name here should be __next__
        if self.count < self.iterend:
            self.count += 1
            self.color = self.sides[random.randint(0,5)]
            return self.color
        else:
            raise StopIteration

if __name__ == '__main__':
    d1 = Dice.get_dice()
    d2 = Dice.get_dice()
    print Dice.calcSum(d1.color,d2.color)
    print '——————iter——cut——————'
    for i in Dice(iterend=6):
        print i
{'fraction_non_alphanumeric': 0.14575866188769415, 'fraction_numerical': 0.018518518518518517, 'mean_word_length': 2.69757174392936, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3148115', 'n_tokens_mistral': 609, 'n_tokens_neox': 594, 'n_words': 120}