the same way you want a new_dict to store anything inside an existing_dict, 
and then some other values.

What you're trying to do

>>> existing_dict = {'a' : 1, 'b' : 2}
>>> wrong_way_dict = dict(c=4, existing_dict)
  File "<stdin>", line 1
SyntaxError: non-keyword arg after keyword arg




>>> existing_dict = {'a' : 1, 'b' : 2}
>>> new_dict = dict(**existing_dict)
>>> new_dict.update(c=3, d=4)
>>> new_dict
{'a': 1, 'c': 3, 'b': 2, 'd': 4}
>>> newer_dict = dict(existing_dict, c=4)
>>> newer_dict
{'a': 1, 'c': 4, 'b': 2}



On Saturday, March 21, 2015 at 2:26:13 AM UTC+1, 黄祥 wrote:
>
> pardon me (for long code), i know that the inproper way to use a dict like 
> that.
> what i want to achieve is i want to assign a vars yet, include the others 
> vars that already stored before.
> for example : 
> 1st user search 'a' (vars search_product = a)
> 2nd time user click next (vars search_product =a & page = 1)
> 3rd time user click sort by highest price (vars search_product =a & page = 
> 1 & sort=highest_price)
>
> how can i achieve it using web2py way?
>
> thanks n best regards,
> stifan
>

-- 
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.

Reply via email to