I think it will make things a lot easier if you spend some time learning Python a little better. That will help you to understand the original code and how to modify it to suit your needs. max() and .get() are standard Python functions -- you should be able to find lots of places to explain what they do.
Anthony On Friday, January 31, 2014 9:30:28 AM UTC-5, 黄祥 wrote: > > pardon, could you explain the meaning of this code, please : > > 1. quantity = max(0, quantity + 1) > 2. quantity = session.purchase_order.get(id, 0) > > what is the 0 (zero) meaning on code above? the code is taken from web2py > appliances pos online store, yet it work when i took the price from the > database, while trying to modify it (the price can be input, modified by > users) i've got the error above. > > the id is the product id that want to buy, when i click the product id = > 3, it return KeyError : 3, when i click the product id = 2, it return > KeyError : 2. > > thanks and 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/groups/opt_out.

