Python Glossary Русский

Python 3.9+zoneinfofunction

zoneinfo.reset_tzpath()

time zones

Resets the list of directories where zoneinfo looks for the time zone database (zoneinfo.TZPATH).

Syntax

zoneinfo.reset_tzpath(to=None)

Paths must be absolute; a relative one raises ValueError. ZoneInfo objects that were already created and cached do not change: the new path affects only keys not loaded yet. It is rarely needed, mostly in tests or with a private copy of the database; with no argument it restores the default path.

Examples

import zoneinfo
zoneinfo.reset_tzpath(['/opt/tz'])
print(zoneinfo.TZPATH)  # → ('/opt/tz',)
zoneinfo.reset_tzpath()
try:
    zoneinfo.reset_tzpath(['relative/dir'])
except ValueError as e:
    print(type(e).__name__)  # → ValueError

See also

Common errors

Open in the full glossarydocs.python.orgReport an inaccuracy