n | import sys | n | |
| | | |
| class Dots: | | class Dots: |
| | | |
| def __init__(self, a, b): | | def __init__(self, a, b): |
| self.a = a | | self.a = a |
| self.b = b | | self.b = b |
| | | |
| def __getitem__(self, item): | | def __getitem__(self, item): |
| if str(item).isdigit() is True: | | if str(item).isdigit() is True: |
| step = (self.b - self.a) / (item - 1) | | step = (self.b - self.a) / (item - 1) |
| return (float(self.a + step * i) for i in range(item)) | | return (float(self.a + step * i) for i in range(item)) |
| elif item.step is None: | | elif item.step is None: |
| step = (self.b - self.a) / (item.stop - 1) | | step = (self.b - self.a) / (item.stop - 1) |
| return float(self.a + step * item.start) | | return float(self.a + step * item.start) |
| else: | | else: |
| step = (self.b - self.a) / (item.step - 1) | | step = (self.b - self.a) / (item.step - 1) |
n | | n | stop = item.stop |
| start = item.start | | start = item.start |
t | stop = item.stop | t | |
| if start is None: | | if start is None: |
| start = 0 | | start = 0 |
| if stop is None: | | if stop is None: |
| stop = item.step | | stop = item.step |
| return (float(self.a + step * i) for i in range(start, stop)) | | return (float(self.a + step * i) for i in range(start, stop)) |