title: How to re-execute same python file
body: <p>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:</p>
  <pre><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(&quot;Running javi build &quot;+build+&quot; [&quot;+lang+&quot;]&quot;)
  print()
  codej = input(&quot;Run &gt;&gt;  &quot;)
  
  try:
    if codej == &quot;&quot;:
      javi(&quot;Null crash&quot;, True)
  except:
    print(&quot;excepted null crash&quot;)
  
  codej = input(&quot;Run &gt;&gt;  &quot;)
  
  if codej == &quot;-version&quot;:
    print(codej)
  elif codej == &quot;L&quot;:
    print(&quot;how dare u L me?? &gt;:(&quot;)
  elif codej == &quot;ඞ&quot;:
    print(&quot;sussy moogus 69420&quot;)
    print(moogus)
    log4javi(&quot;Sussy moogus never trust 69420&quot;, True)
  
  codej = input(&quot;Run &gt;&gt;  &quot;)
  
  def sum(num1, num2):
    print(num1 + num2)
  
  codej = input(&quot;Run &gt;&gt;  &quot;)
  
  # The official print statement
  def sys_println(printarg):
    print(printarg)
  
  codej = input(&quot;Run &gt;&gt;  &quot;)
  
  try: 
    exec(codej)
  except:
    print()
  
  
  </code></pre>
  <p>if anyone can give me some help on re-executing it when it reaches the end i will try it.</p>
  <p>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</p>