problem in dumping the Object by pyYAML
sibteym-pDz3VWC6uHrUEDaH6ef/[email protected]
| Newsgroups | gmane.text.yaml.general |
|---|---|
| Message-ID | <28613.192.168.240.189.1233924640.INFOTECHENTL@webmail.infotechsw.com> |
Hi
I am trying to save the python object using PyYaml but when i
implement the __getattr__() funnction, pyYaml throws an error message
"None type Oject is not callable"
my testing script
import yaml
class Page(yaml.YAMLObject):
yaml_tag = u'!Page'
def __init__(self, pageName):
self.pageName = pageName
self.annotations = {}
def __repr__(self):
return "%s(pageName=%r,annotations=%r)" %
(self.__class__.__name__,self.pageName, self.annotations)
def __getattr__(self, name):
if name in self.annotations:
return self.annotations[name]
try:
filename = r'D:\d2.yaml'
fileObj = file(filename ,'w')
yaml.dump(Page('test'), fileObj)
finally:
fileObj.close()
try:
filename = r'D:\d2.yaml'
stream = file(filename ,'r')
print yaml.load(stream)
finally:
stream.close()
any one can suggest me how to solve this problem
Thanks,
Sibtey
------------------------------------------------------------------------------
Create and Deploy Rich Internet Apps outside the browser with Adobe(R)AIR(TM)
software. With Adobe AIR, Ajax developers can use existing skills and code to
build responsive, highly engaging applications that combine the power of local
resources and data with the reach of the web. Download the Adobe AIR SDK and
Ajax docs to start building applications today-http://p.sf.net/sfu/adobe-com