[Tutor] Problem with "yaml load"
scarolan at gmail.com
Mon Dec 13 18:08:16 CET 2010
I'm trying to define a short function that will import yaml data into
a python dictionary. I am able to do this by dumping my data into a
temporary file and then importing it with yaml.load. I would like to
see if I can eliminate the temporary file and import the data
This works fine:
''' This function grabs facter data and sucks it into a dictionary
called dataMap '''
os.system('facter --yaml > /tmp/sysdata.yaml')
f = open('/tmp/sysdata.yaml')
dataMap = yaml.load(f)
Is there an easy way to do this without writing to a temporary file?
More information about the Tutor