for loops can be broken easily

This commit is contained in:
Wannes 2024-05-29 21:08:40 +02:00
parent ea365e2509
commit f34270bfe1
1 changed files with 21 additions and 0 deletions

21
for.py Normal file
View File

@ -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 = " ")