Dictionaries -- ahh the fun.. (newbie help)

James Stroud jstroud at ucla.edu
Tue May 9 18:51:06 EDT 2006


rh0dium wrote:
> Hi all,
> 
> Can someone help me out.  I am trying to determing for each run whether
> or not the test should pass or fail but I can't seem to access the
> results ..
> 
> Alternatively can someone suggest a better structure ( and a lesson as
> to the reasoning ) that would be great too!!
> 
> cells={}
> 
> cells["NOR3X1"]= {
>                     'run'       : [ 'lvs', 'drc' ],
>                     'results'   : [{ 'lvs' : 'pass' },
>                                    { 'drc' : 'fail' }]
>                  }
> 
> cells["OR3X1"] = {
>                     'run'       : [ 'lvs' ],
>                     'results'   : [{ 'lvs' : 'pass' }]
>                  }
> 
> cells["AND3X1"] = {
>                     'run'       : [ 'drc' ],
>                     'results'   : [{ 'drc' : 'fail' }]
>                  }
> 
> 
> def main():
> 
>     for cell in cells:
>         print cell
>         for run in cells[cell]['run']:
>             print cell, run, "should",
> cells[cell]['results'].index(run)
> 
> 
> I would expect the following
> 
> OR3X1
> OR3X1 lvs should pass
> NOR3X1
> NOR3X1 lvs should pass
> NOR3X1 drc should fail
> AND3X1
> AND3X1 drc should fail
> 

This might be better



cells["NOR3X1"]= {
                     'run'       : [ 'lvs', 'drc' ],
                     'results'   : { 'lvs' : 'pass', 'drc' : 'fail' }
                  }
# etc.
       print cell, run, "should", cells[cell]['results'][run]

James


-- 
James Stroud
UCLA-DOE Institute for Genomics and Proteomics
Box 951570
Los Angeles, CA 90095

http://www.jamesstroud.com/



More information about the Python-list mailing list