Exiting with core.quit() or sys.exit()

Can I safely close the application with sys.exit(‘msg’) or is it necessary to call core.quit()?
I am asking because I have seen a few examles where is sys.exit(‘msg’) used and I do not understand the difference.

The code for core.quit() is here:

As you can see, .core.quit() calls sys.exit() itself, but before that, it does some PsychoPy-specific tidying. So you should use it. In effect core.quit() means “quit PsychoPy and then exit Python”.

Maybe in the examples you found, people used sys.exit() because they are experienced Python programmers but perhaps not so used to the PsychoPy API.

2 Likes