1π
β
The easiest way to understand the difference is with some examples:
In [4]: timezone.now() == timezone.now()
Out[4]: False
In [5]: a = timezone.now()
In [6]: a == a
Out[6]: True
In [11]: print timezone.now() - timezone.now()
-1 day, 23:59:59.999984
In [12]: print a - a
0:00:00
You should notice each time you call timezone.now()
, you get a different time.
π€user1301404
1π
The first function gets the current time and then saves that value in the variable now
. This value is then used twice (unchanged) in the next line.
The second function however calls timezone.now
twice. This means that you will get two different times; one for each call. Granted they will only be off by a few milliseconds at the most, but it is still a difference.
Remember that each time you call timezone.now
, it will return the current time. Consequentially, no two calls will return the same value.
π€user2555451
- [Answered ]-How to select box value can be change in django?
- [Answered ]-How to specify an "upload to" path in a Form File Field in Django?
- [Answered ]-Send Model Data through AJAX in Django
- [Answered ]-TypeError this constructor takes no arguments
- [Answered ]-Syncdb error using mysql
Source:stackexchange.com