save/load multiple properties to/from .txt file

How could I save multiple properties to a .txt file with a python script? Then have a script that loads the value in the .txt and asign it to the same properties? I would like to use this for an inventory system. Any body know?

Not sure but tried to look at other peoples scripts. One example is the Terra siniem game or what ever it’s called… Do you know how to create and write to a text file?

if each property is a string you could:

import os

property1='big axe'
property2='block of cheese'
property3='half a rake'
property4='surfboard'

list=[property1, property2, property3, property4]

#define the path to the database thing - replace with where ever you want it to go
databasepath=os.path.join( os.getenv('HOME'), '.nameofyourgame/database.txt' )

#open it in append mode
database = open(databasepath, 'a') 

for item in list:
    database.write(item)

should work

to return a list of all the items:

import os

databasepath=os.path.join( os.getenv('HOME'), '.nameofyourgame/database.txt' )
databaselines = open(databasepath, 'r').readlines()

return databaselines

Thanks guys. I’ll look at terra sirenum later, and no, I don’t know anything about writing to a .txt file. I’ll also try that script later and see if it works. Later is probably in a week since I don’t have acsess to a computer with python.