-1

I've been looking for a way to re-run my program when it reaches the end, it will normally close the file and I need to re-run it manually. I've been trying to replicate making a programming language with my own modules and files because it's had to understand sly,ply and it has alot of functions and every fix I've seen on other stackoverflow pages don't have my fix. Here is my code:

# main.py

# if program crashes with error code 164 that means it crashed because of invalid syntax or unexpected error in the input you made. contact a developer if you don't know what you did wrong.

import sys
from util.sys import log4javi
from util.sys import *


# Code
print("Running javi build "+build+" ["+lang+"]")
print()
codej = input("Run >>  ")

try:
  if codej == "":
    javi("Null crash", True)
except:
  print("excepted null crash")

codej = input("Run >>  ")

if codej == "-version":
  print(codej)
elif codej == "L":
  print("how dare u L me?? >:(")
elif codej == "ඞ":
  print("sussy moogus 69420")
  print(moogus)
  log4javi("Sussy moogus never trust 69420", True)

codej = input("Run >>  ")

def sum(num1, num2):
  print(num1 + num2)

codej = input("Run >>  ")

# The official print statement
def sys_println(printarg):
  print(printarg)

codej = input("Run >>  ")

try: 
  exec(codej)
except:
  print()


if anyone can give me some help on re-executing it when it reaches the end i will try it.

Python version 3.8.12 64-bit on Ubuntu I also have alot of functions so I don't know if I can store functions on functions

Albi
  • 3
  • 5

1 Answers1

2

Actually, it has a simple answer: infinite loops

Just add a while True (or condition with a counter) in your code.

Example:

# imports....

# defs....

while True:
    # your code for re-run

    # break at some condition; or it can run forever.
stuck
  • 1,477
  • 2
  • 14
  • 30