Loop through a dict changing keys
Gnarlodious
gnarlodious at gmail.com
Sun Oct 16 14:20:49 EDT 2011
On Oct 15, 5:53 pm, PoD <p... at internode.on.net> wrote:
> data = {
> 'Mobile': 'string',
> 'context': '<malicious code>',
> 'order': '7',
> 'time': 'True'}
> types={'Mobile':str,'context':str,'order':int,'time':bool}
>
> for k,v in data.items():
> data[k] = types[k](v)
Thanks for the tip, I didn't know you could do that. I ended up
filtering the values the bulky way, but it gives me total control over
what internet users feed my program.
-- Gnarlie
More information about the Python-list
mailing list