diff --git a/README.md b/README.md index cf6da00..9c4c3c8 100644 --- a/README.md +++ b/README.md @@ -1207,8 +1207,7 @@ class MyCollection: def __init__(self, a): self.a = a def __iter__(self): - for el in self.a: - yield el + return iter(self.a) def __contains__(self, el): return el in self.a def __len__(self): @@ -1224,8 +1223,7 @@ class MySequence: def __init__(self, a): self.a = a def __iter__(self): - for el in self.a: - yield el + return iter(self.a) def __contains__(self, el): return el in self.a def __len__(self): diff --git a/index.html b/index.html index eb94c8b..1d1bea8 100644 --- a/index.html +++ b/index.html @@ -1122,8 +1122,7 @@ lock = threading.RLock(); with lock: ... def __init__(self, a): self.a = a def __iter__(self): - for el in self.a: - yield el + return iter(self.a) def __contains__(self, el): return el in self.a def __len__(self): @@ -1139,8 +1138,7 @@ lock = threading.RLock(); with lock: ... def __init__(self, a): self.a = a def __iter__(self): - for el in self.a: - yield el + return iter(self.a) def __contains__(self, el): return el in self.a def __len__(self):