for loops can be broken easily
This commit is contained in:
parent
ea365e2509
commit
f34270bfe1
|
@ -0,0 +1,21 @@
|
|||
class Foo:
|
||||
def __init__(self, len: int):
|
||||
self.len = len
|
||||
|
||||
def __getitem__(self, key: int):
|
||||
return key
|
||||
|
||||
def __len__(self):
|
||||
return self.len
|
||||
|
||||
for i in Foo(12):
|
||||
print(i)
|
||||
|
||||
if i > 1000:
|
||||
break
|
||||
|
||||
print(*reversed(Foo(12)), sep = " ")
|
||||
|
||||
Foo.__len__ = lambda self: self.len ** 2
|
||||
|
||||
print(*reversed(Foo(12)), sep = " ")
|
Loading…
Reference in New Issue