Comments (5)
I would suggest to completely avoid globals if possible. They do make it harder to test things etc.
from fiscalyear.
It is actually currently possible to do this using the fiscal_calendar
context manager. See https://fiscalyear.readthedocs.io/en/latest/advanced_usage.html#temporarily-changing-the-fiscal-calendar
from fiscalyear.
I am probably at fault, since I mixed two different issues here.
-
I agree that you can use the context manager, even though i am not sure an API like this can scale if you have multiple settings. It feels rather error-prone.
-
Regardless of the previous point, changing how existing objects behave is IMHO not optimal. IMHO changing the setting should only affect new objects. Again, I don't have a strong opinion for this, since in my current use case I will only need to set the settings once.
from fiscalyear.
That's true, we could redesign the API so that things like START_YEAR
, START_MONTH
, and START_DAY
are attributes of every single object we create. Honestly, when I was designing this, I assumed that the majority of people would be working with a single fiscal calendar, and that it would be pretty infrequent that you would have to mix and match fiscal calendars. In reality, this might be more common than I expected.
Do you know of any other Python libraries that allow you to change global variables? It would be interesting to compare my implementation to how others do it. I'm not opposed to changing it to what you propose, but I don't want to change it without a good reason, and I want to make sure I'm changing it in a way that will be stable and maintainable.
from fiscalyear.
I could see some statistical forecasting products breaking with globals such as START_YEAR
, START_MONTH
, and START_DAY
. Easy to avoid if you know about these globals, but could trip the occasional person.
from fiscalyear.
Related Issues (12)
- Support for a 4-4-5 calendar HOT 1
- Syntactic sugar for getting the current Fiscal{Year,Quarter} HOT 2
- Add a function for easily changing the global "START_*" parameters HOT 2
- FiscalCalendar starting on 31st day of the month throws ValueError HOT 2
- Support for week number of a date in a FiscalYear HOT 20
- Incorrect fiscal_day returned for last day of the year HOT 1
- Fiscal Month Offset HOT 7
- Support February 29 month end date for leap year HOT 5
- FY=2022 for US 2021 calendar year HOT 1
- [Question/Feature Request]: Convert from FY to CY HOT 4
- [Question]: Why is the implementation primarily inside of `__init__.py`? HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from fiscalyear.