hao ramirez hao ramirez - 1 year ago 77
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!

Answer Source

result is a datetime object

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

result is not changing at all. utcnow() is

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download