But what if you're already writing your game in python?
Common wisdom seems to say that game assets should be stored in files outside of the game's code. This is a good idea, but it also lends itself to the strange idea that this data must be stored in some other format as well.
Today I asked myself "If I'm writing the game in Python and I need a file format for storing structured data, couldn't I just use more Python?"
It turns out that the answer is yes.
I'm not suggesting that it's a good idea to just throw random data around in your source files; that part of the original premise is true. Data should be separated from the game's core behavior. My data scripts are stored in a separate location and loaded by the main game in a fairly strict environment to ensure that they don't get tangled up with the main code.
This approach seems like it's going to have a lot of advantages because these external scripts can be as simple or as complex as I need them to be. A script could just contain a bunch of static data that gets injected into the game, or it could contain actual logic that generates large amounts of content based on a relatively small amount of data.
It also gives me a good place to put specialized game logic for things like puzzles or enemy behavior which can often be quite complex but really don't belong inside the engine proper.
Of course it's possible this approach won't be all that great. Every line of code carries the risk of horrible side effects you forgot to consider. Only time will tell .