diff --git a/main.py b/main.py index 93a666b..6dcd593 100644 --- a/main.py +++ b/main.py @@ -1,31 +1,24 @@ -#Train Class Example -class Train: - def __init__(self, class_, name): - self.class_ = class_ - self.name = name - self.name = name if name else "#" - def __str__(self): - return f"Class {self.class_}({self.name})" - def manufacturer(self): - return "" +#Iteration test +a = (1, 2, 3) +b = iter(a) +print(next(b)) +print(next(b)) +print(next(b)) -class BREL(Train): - def __init__(self, class_): - super().__init__(class_, "") - def manufacturer(self): - return "BREL" - -class PEP(Train): - def __init__(self, class_): - super().__init__(class_, "PEP") - def manufacturer(self): - return "Unknown" - -#The presendence of definitions is the order in the inheritance bracket -class C315(BREL, PEP): +class A: def __init__(self): - super(BREL,self).__init__(315) - -c315 = C315() -print(c315, c315.manufacturer()) -del c315 + self.n = 0 + def __init__(self, n): + self.n = n + def __iter__(self): + self.i = 0 + return self + def __next__(self): + if self.i > 100 or self.i < -100: raise StopIteration + z = self.i + self.i -= self.n + return z +c = A(2) +d = iter(c) +for x in d: + print(x)