Python question

Bruno Desthuilliers onurb at xiludom.gro
Mon Jun 26 05:10:58 EDT 2006


Harry wrote:
> Hi All,
(snip)
> I have the following object which is like a list of tuples

> row= [('name', 'x1'), ('min', 15.449041129349528), ('max',
> 991.6337818245629), ('range', 976.18474069521335), ('mean',
> 496.82174193958127), ('stddev', 304.78275004920454), ('variance',
> 92892.524727555894), ('mode', '46.5818482111'), ('unique_count', '99'),
> ('count', 99.0), ('count_missing', 0.0), ('sum_weight', 99.0)]

FWIW, it *is* a list of tuples.

> What command

<ot> What's a 'command' ? </ot>

> do I use to get the value corresponding to 'min'?
(see below...)

> This object seems to be non-indexable

It is - just like any other list. Try :
 print row[0]
 print row[1]
 # etc...

Now if you want keyword access, try this:
 print dict(row)['min']



-- 
bruno desthuilliers
python -c "print '@'.join(['.'.join([w[::-1] for w in p.split('.')]) for
p in 'onurb at xiludom.gro'.split('@')])"



More information about the Python-list mailing list