[Python] Creare un dictionary in python 2.6 and python 2.7
    Valerio Maggio 
    valerio.maggio a gmail.com
       
    Lun  7 Lug 2014 14:32:41 CEST
    
    
  
emmanuel segura wrote:
> Ciao a tutti,
> 
> Mi rispondo da solo
> http://stackoverflow.com/questions/1747817/python-create-a-dictionary-with-list-comprehension
Bene, hai fatto prima di me! :)
In ogni caso, per tutti (come riportato su SO):
In Python 2.6 (o precedenti), `dict` constructor:
	`d = dict((x, x*2) for x in range(10))`
In Python 2.7+ or 3, la "dict comprehension":
	`d = {x: x*2 for x in range(10)}`
Ciao,
V.
    
    
       
       Maggiori informazioni sulla lista 
	       Python