hao ramirez hao ramirez - 9 months ago 46
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()
>>> result.utcnow().isoformat()

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!


result is a datetime object

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

result is not changing at all. utcnow() is