[Tutor] Is there an easy way to combine dictionaries?
Pierre Barbier de Reuille
pierre.barbier at cirad.fr
Tue Sep 6 13:58:23 CEST 2005
Is this what you want ?
c = dict(a)
c.update(b)
Pierre
Lane, Frank L a écrit :
> Hi List,
>
> Is there an easy way to combine dictionaries?
>
> e.g.
>
> a = {}
> b = {}
>
> a = {'a':'a', 'b':'b', 'c':'c'}
> b = {'1':1, '2':2, '3':3}
> c = a + b # doesn't seem to work
>
> desired:
> c = {'a':'a', 'b':'b', 'c':'c', '1':1, '2':2, '3':3}
>
> Thanks,
> Frank
>
>
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> Tutor maillist - Tutor at python.org
> http://mail.python.org/mailman/listinfo/tutor
--
Pierre Barbier de Reuille
INRA - UMR Cirad/Inra/Cnrs/Univ.MontpellierII AMAP
Botanique et Bio-informatique de l'Architecture des Plantes
TA40/PSII, Boulevard de la Lironde
34398 MONTPELLIER CEDEX 5, France
tel : (33) 4 67 61 65 77 fax : (33) 4 67 61 56 68
More information about the Tutor
mailing list