Arrgh! Please help.
Jerome Chan
eviltofu at rocketmail.com
Sat May 13 23:38:46 EDT 2000
In article <391e0f88.90186331 at news1.on.sympatico.ca>,
chibaA at TinterlogD.Tcom wrote:
> Yeah... it says the value is int - which obviously won't work.
>
> Is there any way to FORCE fields to be of string? Here's the way that
> I'm defining that dictionary:
>
> rv = {}
> rv['id'] = '3'
>
> etc., etc..
>
> and it assigns it an INT.??
>
> Thanks again,
>
> kc
>
>From my Python interpreter:
>>> rv = {}
>>> rv['id'] = '3'
>>> rv.items()
[('id', '3')]
>>> for key,value in rv.items(): print key,value
...
id 3
>>> for key,value in rv.items(): print type(key),type(value)
...
<type 'string'> <type 'string'>
>>>
So it does look like it's a string.
Check your data entry again, maybe you entered it as rv['id'] = 3
If you are really paranoid:
import types
oL = ''
for value in rv.values():
if type(value)!=types.StringType:
aValue = str(value)
else:
aValue = value
oL = oL + aValue + '&' + 'blah'
print "blah = %s" % oL
More information about the Python-list
mailing list