Chris,
This looks similar to what I do for my job. I
would be happy to help you, if I
can.
My first question is, how would you like the output
to look? Can you manually create a model of the email text you want to
send?
My second question is, can you create the
email content on the fly instead of creating a dictionary, or are you
constrained to using a dictionary for some reason?
Dave
-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Chris Hallman
Sent: Wednesday, July 26, 2006 9:45 AM
To: tutor@python.org
Subject: [Tutor] dictionary manipulation
I need some suggestions on how to work with a dictionary. I've got a program that builds a dictionary. I need to be able to manipulate the different keys and data so that I can write the output to a file AND utilize the smtplib to send the data in an email. I had problems using the data in the dictionary, so I wrote a crude for loop to strip characters:
>>> print result
{'s0100swa': ['running correct IOS'], 's0300swa': ['INCORRECT running IOS'], 's0200swa': ['running correct IOS'], 's0400swa': ['running correct IOS']}
results= sorted(result.items ())
>>> print results
[('s0100swa', ['running correct IOS']), ('s0200swa', ['running correct IOS']), ('s0300swa', ['INCORRECT running IOS']), ('s0400swa', ['running correct IOS'])]
for x in range(len(results)):
text = repr(results[x])
text = text.replace("'", "")
text = text.replace("(", "")
text = text.replace(")", "")
text = text.replace ("[", "")
text = text.replace("]", "")
text = text.replace(",", ":")
output.write(text + "\n")
output.flush()
output.write ("\n")
I need to remove the extra characters so the file and email output isn't difficult to read. I also need to be able to use the dictionary data so that I can compose the message used by the smtplib.
Any suggestions?
Thanks!!
_______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor