[EMAIL PROTECTED] wrote:
for foo in sc.query(sql).dictresult(): <- this returns a dict of the
result
f=dict(foo)
for k in f.iteritems()
if k == '^Hostname': <-- need this sort of
behaviour - match a partial string.
print "%s" % f[3] <-- ..and if true, need to pull
out the 4th column on that line.
This breaks spectacularly -
Several observations:
* "breaks spectacularly" is not a useful description of a failure. If
you get an exception, show us the exception. If you get an unexpected
result, show us the result and tell us how it differs from the result
you expected.
* To check whether a string starts with a given string, use the
startswith() method: if k.startswith("Hostname"): ...
* Why the "f=dict(foo)"? Isn't foo already a dictionary?
* Since f is a dictionary, presumably keyed on column names, f[3] is
unlikely to work. You're going to have to use the name of the fourth
column to pull out the value you're looking for.
HTH,
--
Carsten Haese
http://informixdb.sourceforge.net
--
http://mail.python.org/mailman/listinfo/python-list