Eduardo Vieira wrote:
Hello, I thought I understood **kwargs until I stumbled with this function:
def changeflexion(myword, mytag, **dicty):
global er_verbs
global ar_verbs
global ir_verbs
# global dicty
for item in dicty:
if myword in item and mytag in item[1]:
if dicty[item].endswith('ar'):
ending = item[0].replace(dicty[item][:-2], "")
try:
return dicty[item][:-2] + ar_verbs[ending]
except KeyError:
return item[0]
elif dicty[item].endswith('er'):
ending = item[0].replace(dicty[item][:-2], "")
try:
return dicty[item][:-2] + er_verbs[ending]
except KeyError:
return item[0]
elif dicty[item].endswith('ir'):
ending = item[0].replace(dicty[item][:-2], "")
try:
return dicty[item][:-2] + ir_verbs[ending]
except KeyError:
return item[0]
else:
return item[0]
but when I import the module and call:
a = conjugate.changeflexion('estaban', 'VLFin', conjugate.mydict)
I get this error:
TypeError: changeflexion() takes exactly 2 arguments (3 given)
**dicty accumulates any name=value pairs in the call into a dictionary.
Isn't the 3rd argument supposed to be a dictionary?
If you want that remove the ** from dicty.
--
Bob Gailer
Chapel Hill NC
919-636-4239
_______________________________________________
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor