Ho una funzione argomento parola chiave:argomenti pitone parole chiave con trattino
def f1(**kw):
for key,val in kw.iteritems():
print "key=%s val=%s" % (key,val)
f1(Attr1 = "Val1", Attr2 = "Val2") # works fine.
f1(Attr1-SubAttr = "Val1", Attr2 = "Val2") # complains about keyword being an expression.
f1("Attr1-SubAttr" = "Val1", Attr2 = "Val2") # doesn't work either.
Come faccio a passare in parole chiave con un trattino? Non ho il controllo su queste parole chiave poiché sto analizzando queste da un database legacy esistente.
Grazie! -kumar
Non si può avere le parole chiave con un trattino. – wim
è una buona idea versione: http://stackoverflow.com/questions/16956364/function-accepts-keyword-arguments-that-are-not-identifiers –