get an Array of global Variables?

I’m currently working on a “save everything” script and so far it’s working properly. But i hit a snag. is there any way to get a list of all global variables being used in the scene? I’m trying to keep it as ambiguous as possible so it can be added to any game without any tedious setup. Thanks for any help!

I don’t know if there is a specific function that would retrieve a list of all the newly added members by the user, on a module like GameLogic, but provided that you can run this at the very beginning:

GameLogic.base_set = set(dir(GameLogic))

You can then get the difference like this:

GameLogic.blah = "something"

new_set = set(dir(GameLogic))
delta_set = new_set - GameLogic.base_set     # "blah"

for element in delta_set:
    if element != "base_set":
        print GameLogic.__dict__[element]     # something

Although, I don’t think this will be enough to create a “save everything” script: Global variables can store any arbitrary python object (including game object references), and so can the KX_GameObject (owner).

Now, for the game object itself, you can just get the name, and use that to recreate a copy on subsequent “game load”, but unless you can serialize every python object that the owner contains, and all the objects that those objects might contain… It doesn’t seem that easy.

Although, serialization is not my specialty, so I can’t say for sure (I just use cPickle to save what I need in any particular situation).