Bruno Desthuilliers wrote: > placid wrote: > > Duncan Booth wrote: > > > >>placid wrote: > >> > >> > >>>Hi all, > >>> > >>>Can someone tell me what * in the following code means/does a Google > >>>search didnt turn up anything as i dont know what the * is called > >>>(related to Python and i dont think Python has pointers) > >>> > >> > >>* is for variable number of positional arguments, ** is for variable > >>keyword arguments. The syntax is symmetrical when defining functions and > >>when calling them. > >> > >>See http://docs.python.org/ref/calls.html > >>and http://docs.python.org/ref/function.html > > > > > > so * basically means that args is a list > > A tuple IIRC > > > containing more arguments that > > can change in size, whereas ** means that args is a dictionary of > > key=value arguments? > > > > Why don't you try by yourself in the Python shell ? One of the nice > things with Python is that it's quite easy to explore and experiment.
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) > > > -- > bruno desthuilliers > python -c "print '@'.join(['.'.join([w[::-1] for w in p.split('.')]) for > p in '[EMAIL PROTECTED]'.split('@')])" -- http://mail.python.org/mailman/listinfo/python-list