below is the text file i have How to create Facility as a key and then assign multiple values to it
FACILITY : BACKUP
FAILED BACKUP_BEFORE
FAILED BACKUP_INTERCHANGE
Total : 34
Passed : 32
Failed : 2
Not Run : 0
FACILITY : CDU
Total : 9
Passed : 9
Failed : 0
for example Facility BACKUP is a key & its values are Total Passed, Failed Not Run and Facility CDU as a key & its values Total:9,Passed:9,Failed:0 etc...
On Tue, 09 Oct 2012 04:59:49 -0700, argbsk wrote:
> below is the text file i have How to create Facility as a key and then
> assign multiple values to it
To use Facility as a key in a dict:
d = {}
d['Facility'] = 'ham'
Note that keys are case-sensitive, so that 'Facility', 'facility', 'FACILITY' and 'FaCiLiTy' are all different.
To have multiple values assigned to a key, use a list:
Or, somewhat more work, but a richer solution, create a FacilityData class, whose attributes are total, passed, failed, not_run, etc, and have instances of FacilityData be the values.