hi!
Don't worry it's pretty common question for newcomers :)
This is called Function Argument Packaging and Function Argument
Unpackaging.
arguments could be packaged into list or dictionary:
* - position based arguments
** - name based arguments
>>> def f(*a, **b):
return a, b
>>> x, y = f(3, 'hello', c=4, test='world')
>>> print x
(3, 'hello')
>>> print y
{'c':4, 'test':'world'}
and vice versa, arguments could be extracted for functions
>>> def f(a, b):
return a + b
>>> c = (1, 2)
>>> print f(*c)
3
>>> def f(a, b):
return a + b
>>> c = {'a':1, 'b':2}
>>> print f(**c)
3
On Wednesday, March 19, 2014 7:06:31 AM UTC+2, Chops wrote:
>
> I am just learning Web2py
>
> I have an understanding of dict but now I find it used with two asterisks
> before it and I can't seem to find an explanation!!
>
> Can it be used with anything other than a form? ((**dict(form.vars))?
>
> Can I use the two asterisks on other bits of code to server a common
> purpose?
>
> Thanks in advance
>
--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
---
You received this message because you are subscribed to the Google Groups
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.