fix :__main__ not working within interpreter

This commit is contained in:
martin legrand
2025-04-15 20:56:58 +02:00
parent e1d55649d5
commit 6d1edf9184
4 changed files with 12 additions and 2 deletions
+7
View File
@@ -0,0 +1,7 @@
def print_hello():
hello = "Hello World"
print(hello)
if __name__ == "__main__":
print_hello()
+4
View File
@@ -30,6 +30,7 @@ class PyInterpreter(Tools):
'__builtins__': __builtins__,
'os': os,
'sys': sys,
'__name__': '__main__'
}
code = '\n\n'.join(codes)
try:
@@ -93,6 +94,9 @@ here is a save test
def print_hello():
hello = "Hello World"
print(hello)
if __name__ == "__main__":
print_hello()
```
"""
py = PyInterpreter()