Re: [web2py] Re: differntial of request.args[0] and request.args(0)
a, i'm understand right now, thank you so much for your detail explaination all. On Mon, May 16, 2011 at 12:51 AM, pbreit wrote: > Just remember that the () method is unique to Web2py "strorage" objects and > cannot be used generally in Python. > > Same for request.vars (web2py) vs. request['vars'] (python). > > http://web2py.com/book/default/chapter/04#request > > Is that correct everyone? >
Re: [web2py] Re: differntial of request.args[0] and request.args(0)
That is correct, except it really is python that Massimo has done here. It's a convenience method that he has created for this very issue as it happens a lot. On 05/15/2011 08:51 PM, pbreit wrote: Just remember that the () method is unique to Web2py "strorage" objects and cannot be used generally in Python. Same for request.vars (web2py) vs. request['vars'] (python). http://web2py.com/book/default/chapter/04#request Is that correct everyone?
Re: [web2py] Re: differntial of request.args[0] and request.args(0)
Just remember that the () method is unique to Web2py "strorage" objects and cannot be used generally in Python. Same for request.vars (web2py) vs. request['vars'] (python). http://web2py.com/book/default/chapter/04#request Is that correct everyone?
Re: [web2py] Re: differntial of request.args[0] and request.args(0)
i'm understand right now, thank you so much for your detail explaination ron On Sun, May 15, 2011 at 2:08 PM, ron_m wrote: > In the core chapter of the book I found this: > > In the above example, both request.args[i] and request.args(i) can be used > to retrieve the i-th element of the request.args, but while the former > raises an exception if the list does not have such an index, the latter > returns None in this case. > > I would use request.args(0) and test for None if it is legal for the arg to > not to be there on some requests. Conversely, if arg 0 is always supposed to > be part of the request then request.args[0] would generate an exception and > a ticket indicating a failure condition when it is missing. > >
[web2py] Re: differntial of request.args[0] and request.args(0)
In the core chapter of the book I found this: In the above example, both request.args[i] and request.args(i) can be used to retrieve the i-th element of the request.args, but while the former raises an exception if the list does not have such an index, the latter returns None in this case. I would use request.args(0) and test for None if it is legal for the arg to not to be there on some requests. Conversely, if arg 0 is always supposed to be part of the request then request.args[0] would generate an exception and a ticket indicating a failure condition when it is missing.