hao ramirez hao ramirez - 2 months ago 6
Python Question

Why does the result variable update itself?

I have the following code:

result = datetime.datetime.now() - datetime.timedelta(seconds=60)


>>> result.utcnow().isoformat()
'2016-09-23T18:39:34.174406'
>>> result.utcnow().isoformat()
'2016-09-23T18:40:18.240571'


Somehow the variable is being updated... and I have no clue as to how or how to stop it. What is this called? How do I prevent it?

Thank you!

Answer

result is a datetime object

datetime.utcnow() is a class method of all datetime objects.

result is not changing at all. utcnow() is

Comments