How to create a data set of points in Python

1 Answer

0 votes
from itertools import *     
import pprint

class CPoint:         
    def __init__(self, x, y):             
        self.x = x             
        self.y = y
        
    def __repr__(self):             
        return '({}, {})'.format(self.x, self.y)         

    def __gt__(self, other):             
        return (self.x, self.y) > (other.x, other.y)
        

# 4 = 0, 1, 2, 3
lst = list(map(CPoint, cycle(islice(count(), 4)), islice(count(), 10)))   

pprint.pprint(lst, width=2)  



'''
run:

[(0, 0),
 (1, 1),
 (2, 2),
 (3, 3),
 (0, 4),
 (1, 5),
 (2, 6),
 (3, 7),
 (0, 8),
 (1, 9)]
 
'''

 



answered May 24, 2019 by avibootz
edited May 24, 2019 by avibootz
...