I know this sounds confusing, but basically I want to run another python file (a.py) through my main.py file when the user presses the key "p" and then close main.py while a.py is still running. I have tried multiple different ways to force main.py to stop running, but it always closes only after a.py exits.
Here's my code for this part (I'm using pygame):
import pygame
import os
gameOver = False
while not gameOver:
for event in pygame.event.get():
if event.type == pygame.KEYDOWN:
if event.key == pygame.K_p:
os.system("a.py")
gameOver = True
#the rest of the game
Thanks for your help!