converting dict to object

Neil Cerutti horpner at yahoo.com
Sat Dec 2 10:54:32 EST 2006


On 2006-12-02, Michel Claveau <mcPas.De.Spam at mclaveauPas.De.Spam.com> wrote:
> Hi!
>
> Yes.
>
> But...
>
> Try:    d = {'a': 1, 'b': 2, 'def': 123}
>
> Ok, I go out...

How to convert a list of strings into a list of integers:

 a = ['82', '4', '16']

 ai = [int(i) for i in a]

Yes.

But...

Try:  a = ['82', '4', '16', 'foo']

Ok, I go out...

-- 
Neil Cerutti



More information about the Python-list mailing list