will continue to work with the old version of the imported objects. If the
module contains class definitions, existing class instances will *not* be
updated to use the new class definition. This can result in the following
-paradoxical behaviour:
+paradoxical behaviour::
>>> import importlib
>>> import cls
False
The nature of the problem is made clear if you print out the "identity" of the
-class objects:
+class objects::
>>> hex(id(c.__class__))
'0x7352a0'
>>> from datetime import datetime
- >>> datetime.now().isoformat(timespec='minutes')
+ >>> datetime.now().isoformat(timespec='minutes') # doctest: +SKIP
'2002-12-25T00:00'
>>> dt = datetime(2015, 1, 1, 12, 30, 59, 0)
>>> dt.isoformat(timespec='microseconds')
else:
return dt
-Example :class:`tzinfo` classes:
+In the following :download:`tzinfo_examples.py
+<../includes/tzinfo_examples.py>` file there are some examples of
+:class:`tzinfo` classes:
-.. literalinclude:: ../includes/tzinfo-examples.py
+.. literalinclude:: ../includes/tzinfo_examples.py
Note that there are unavoidable subtleties twice per year in a :class:`tzinfo`
subclass accounting for both standard and daylight time, at the DST transition
``astimezone(Eastern)`` won't deliver a result with ``hour == 2`` on the day DST
begins. For example, at the Spring forward transition of 2016, we get
+ >>> from datetime import datetime, timezone
+ >>> from tzinfo_examples import HOUR, Eastern
>>> u0 = datetime(2016, 3, 13, 5, tzinfo=timezone.utc)
>>> for i in range(4):
... u = u0 + i*HOUR