* in Python
duncan.booth at invalid.invalid
Fri Jun 23 16:29:42 CEST 2006
> i did try it in a Python shell after i learnt what it was. Like i said
> *args will be a list, but when i try **args with the following code it
> doesnt work
> def test(**args):
> keys = args.keys()
> for key in keys:
> print key+"="+args(key)
When you post here, it helps if instead of saying 'it doesnt work' you say
what you expected to happen and what actually happened (and quote exact
error messages, dont paraphrase them).
If I try your code it works fine: it defines a function.
If I try to call your function, even though you didn't include a call in
what 'doesnt work', then I get the exception I would expect, namely that
you are trying to call args as though it were a function 'args(key)'
instead of subscripting it as a dictionary 'args[key]'. Fixing that will
then generate a different error, but I'm sure you'll be able to figure it
More information about the Python-list