wilsonfreitas / python-bizdays

Business days calculations and utilities
http://wilsonfreitas.github.io/python-bizdays/
MIT License
80 stars 34 forks source link

Use context manager to change options locally #46

Open wilsonfreitas opened 10 months ago

wilsonfreitas commented 10 months ago

A project might set a specific option to bizdays. But in another part, it needs to change this option. This should be done locally with context managers.

from bizdays import set_option, Calendar, option

set_option("mode", "pandas")
cal = Calendar.load("B3")

with bizdays.option("mode", "datetime"):
    cal.bizdays(date1, date2)