How can I change function names so that Python will read hehe as if, haha as elif and hihi as else. Code right now is something like:
if x == 7 or x == 2:
print(":)")
elif x == 3:
print(":(")
else:
print(":|")
I want my code to be like this:
hehe x == 7 or x == 2:
print(":)")
haha x == 3:
print(":(")
hihi:
print(":|")
I want to change every function's name to make the code completely unreadable. This has no practical usage, I want to make it just for fun. I tried to make a compiler and I've got something similar to basic, but I want to make it in Python without creating a compiler. There should be a solution with dictionaries where the format will be like:
dict = {
"if": "hehe"
"elif": "haha"
"else": "hihi"
}
But I don't know how to make it work in code so I could write code in this "new language" after
I haven't spent along time on this (it could be improved), this is my first time using the tokenize module, but here's what I came up with.
As I was looking for a python parser I found this module, it basically parses python code and categorizes it, from there you can do what you want with it.
update
the previous code, only encodes, with some minor alterations, you can reuse the same code to decode and encode the script:
check out the official docs for more information i am no expert my self but don't hesitate to ask anything here.
very happy to help good luck, happy coding