Quote:
Originally Posted by Game_Ender
You don't really have to use XML. You just need a structured data format you could use Json with the Python
simplejson library.
Here is a usage example: import simplejson # file mycards.txt # { # "Blue Eyes White Dragon" : { # "hitpoints" : 1202020 # "attacks" : ["Fire Spin", "Tail Whip"] # } # } mycards = file("mycards.txt") myData = simplejson.load(mycards.read()) hitpoints = myData["Blue Eyes White Dragon"]["hitpoints"]
XML might be a good data interchange format, but its pretty verbose, and a pain to work with by hand compared to Json and Yaml. The key is, there is no "parsing" with Json or Yaml. They are already in dict + list format. The data structure in the file exactly maps to python. No hoop jumping or awkward APIs.
|
Thank you! That's just what I was looking for. At first XML seemed like a great idea, but then I realized the unnecessary difficulty of parsing it in Python. Thanks again for the help; now I think that I can finally get to work on my game.
Edit: I installed simplejson, and it's completely PERFECT for what I need. It works just as well as I hoped it would. Thanks once again for your assistance.