Import objects from user input? (Python)

I am working on a game where the player can have multiple save games at once, and the player has to input the name of the savefile they want. How do I then convert their input into importing their chosen savefile?

You are viewing a single comment. View All

@MuffinsTheCat The other issue with using a Python file to do this is that the file is executed, meaning of someone tried to load a maliciously-crafted save file, unintended arbitrary code execution could take place. For example, if it was made so that "health" was "1;print('hacked')", the savefile would be this:

When imported, this save file will print "hacked".