[PIPython] problema mappa

Lawrence Oluyede l.oluyede
Mar 24 Maggio 2005 17:55:08 CEST


Il 24/05/05, Mariano Di Felice<mardif a eprometeus.com> ha scritto:
> ciao a tutti.
> 
> data la seguente mappa:
> 
> {('arial', True, False): 'arialbd', ('arial', True, True): 'arialbi',
> ('arial', False, True): 'ariali', ('arial', False, False): 'arial',
> ('times new roman', True, False): 'Timesb', ('times new roman', True,
> True): 'timesbi', ('times new roman', False, True): 'timesi', ('times
> new roman', False, False): 'times'}
> 
> Ora io non ho la chiave, ma il valore: come faccio a ricacciarmi la
> chiave dal valore?

Non c'e` un "modo", i dizionari son strutture dati indicizzate tramite
le chiavi.
Un dizionario del genere {1: 3, 2: 3} è perfettamente valido in Python
(e in ogni altro linguaggio che implementi l'hash). Puoi provare ad
usare il metodo .items() e iterare sulle tuple ritornate, dai
un'occhiata qui:
http://docs.python.org/lib/typesmapping.html

Ciao


-- 
Lawrence
http://www.oluyede.org/blog


More information about the Python mailing list