On Wed, Feb 17 2016, Dario Santomarco wrote: > Ciao, ci sono i seguenti errori: > Tua - kwargs = {1:"A", 2:"B", 3:"C"} > Corretta - kwargs = {'1':"A", '2':"B", '3':"C"} # le chiavi del > dizionario DEVONO essere stringhe
Spiacente di contraddirti ma: $ python Python 2.7.9 (default, Mar 1 2015, 12:57:24) [GCC 4.9.2] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> {1: "1"}[1] '1' >>> {(1,2): "una tupla"} {(1, 2): 'una tupla'} >>> {[1,2]: "una lista"} Traceback (most recent call last): File "<stdin>", line 1, in <module> TypeError: unhashable type: 'list' >>> {object(): "un oggetto"} {<object object at 0x7fd9eb1ed080>: 'un oggetto'} >>> come puoi vedere le chiavi di un dizionario possono essere tante cose, e l'errore con la lista ti dà un indizio su cosa può e non può essere una chiave di dizionario. m. _______________________________________________ Python mailing list Python@lists.python.it http://lists.python.it/mailman/listinfo/python