Comparing strings - akin to Perl's "=~"

krumblebunk at gmail.com krumblebunk at gmail.com
Tue May 6 09:37:00 EDT 2008


On May 6, 2:23 pm, "A.T.Hofkamp" <h... at se-162.se.wtb.tue.nl> wrote:

....

> Without a explicit Python value of what comes out of the sql query, I can only
> guess. As example, assume the following data:
>
> f = { 1: ['Hostname', 'blabla', 'person', 'john'],
>       2: ['MachineName', 'blabla', 'company', 'something']}
>
> ie a dictionary of column number to rows.
>
> Here you are only interested in the value part, and the code becomes.
>
> for v in f.itervalues():
>   if v[0].startswith('Hostname'):
>      print v[3]

Many thanks for all your replies - this last snippet of code helped
me, extra thanks!

kb.



More information about the Python-list mailing list