Python but even worse

From Esolang
Jump to navigation Jump to search

Python but even worse is like Python, but it deletes its code if it doesn't raise an error.

In Python, if the end of program is a wrong command, it will raise an error, but in this Esolang, the program will execute normally and Successfully.

It's invented by User:None1.

Example Programs

Hello World

print("Hello World!")
print(x) # Note that X is don't defined

Cat Program

import sys
print(sys.stdin.read())
a = 1 / 0

FizzBuzz

for i in range(1,101):
    if i%3==0:
        print("Fizz",end="")
    if i%5==0:
        print("Buzz",end="")
    if i%3 and i%5:
        print(i,end="")
    print()
a = 6128576217835128956872345782136587236578132651872365823164821587623951293846125778123658723148712635231513279 / (0 / 0)

Interpreter in Python

import os,sys
with open(sys.argv[1],"r",encoding="utf-8") as f:
    c=f.read()
try:
    exec(c)
except:
    pass
else:
    os.remove(sys.argv[1])

Note that it is also possible to write an interpreter in C/C++ using Python C APIs.

See also