this is my code:
#!/usr/bin/env python
#==========================================#
# Copyright Tom Tetlaw & Shadwick (c) 2009 #
#==========================================#
import pickle as pk
from formatting import *
from gclasses import *
from gfuncs import *
from items import *
from objs import *
class Actor(object):
def __init__(self, name, age, race, profession):
self.attributes = {
"name":name,
"age":age,
"race":race,
"profession":profession,
}
self.attrs = ["name", "age", "race", "profession"]
def saveAttributes(self, charactor):
fout = open('charactors/' + charactor + '.actor', 'r')
lists = [self.attributes, self.attrs]
pk.dump(lists, fout)
fout.close()
def loadAttributes(self, charactor):
fout = open('charactors/' + charactor + '.actor', 'r')
att = pk.load(fout)
fout.close()
return att
def printAttrs(self):
for item in self.attrs:
print repr(self.attrs.index(item)) + ') ' + self.attributes[item]
def changeAttr(self, attr, val):
self.attributes[attr] = val
def addAttr(self, attr, val):
self.attributes[attr] = val
class Citizen(Actor):
def __init__(self, name, age, race, profession, awesomeness):
self.awesomeness = awesomeness
Actor.__init__(self, name, age, race, profession)
self.addAttr("awesomeness", self.awesomeness)
a_person = Citizen('a person', 15, 'human', 'assassin', 190999)
a_person.saveAttributes('person')
this is my error:
Traceback (most recent call last):
File "actor.py", line 9, in <module>
from formatting import *
File "C:\Documents and Settings\tom\Desktop\python text game\src\engine\format
ting.py", line 2, in <module>
from objs import *
File "C:\Documents and Settings\tom\Desktop\python text game\src\engine\objs.p
y", line 2, in <module>
from actor import *
File "C:\Documents and Settings\tom\Desktop\python text game\src\engine\actor.
py", line 56, in <module>
a_person.saveAttributes('person')
File "C:\Documents and Settings\tom\Desktop\python text game\src\engine\actor.
py", line 29, in saveAttributes
pk.dump(lists, fout)
File "c:\Python25\lib\pickle.py", line 1362, in dump
Pickler(file, protocol).dump(obj)
File "c:\Python25\lib\pickle.py", line 224, in dump
self.save(obj)
File "c:\Python25\lib\pickle.py", line 286, in save
f(self, obj) # Call unbound method with explicit self
File "c:\Python25\lib\pickle.py", line 597, in save_list
write(MARK + LIST)
IOError: [Errno 0] Error
any help would be appreciated :)