Thanks Anthony for the explanation. We am using #1 and occasionally get '*insufficient data left in message*', could it be because of datetime.now?
On Thursday, 7 November 2013 17:56:47 UTC+5, Anthony wrote: > > Is there any difference between following two statements: >> #1 >> from datetime import datetime >> db.my_table.insert(updated=datetime.now) >> >> and >> #2 >> from datetime import datetime >> db.my_table.insert(updated=datetime.now()) >> > > I believe they should result in (almost) the same entry into the database. > In #1, you are technically inserting the function datetime.now. However, > ultimately, the value inserted will be str(datetime.now), which turns out > to be the string representation of datetime.now(). So, the only difference > is that in the second case, the value of datetime.now() is determined > before the .insert() method is called, and in the first case, the value is > determined within the call to .insert() (the difference in time would > probably only be microseconds). > > Note, you should use #2, as the fact that #1 works is due to an > implementation detail (i.e., the fact that str() is applied to the value > provided) -- you should not rely on that behavior, as it could change in > the future, which would break your code. > > Anthony > > -- 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.

