def get_imei(n):
    def luhn_residue(digits):
        """Luhn algorithm"""
        return sum(sum(divmod(int(d) * (1 + i % 2), 10))
                   for i, d in enumerate(digits[::-1])) % 10

    part = ''.join(str(random.randrange(0, 9)) for _ in range(n - 1))
    res = luhn_residue('{}{}'.format(part, 0))
    return '{}{}'.format(part, -res % 10)
Generate a (JSON-compatible) dictionary with resource data.
dataset/ETHPy150Open allegro/ralph/src/ralph/data_importer/management/commands/demodata.py/get_imei--crossover with--dataset/ETHPy150Open wichert/rest_toolkit/src/rest_toolkit/abc.py/ViewableResource.to_dict