Be conservative in what you do, be liberal in what you accept from others.
"Lazy" code (per The Pragmatic Programmer):
Be strict in what you will accept before you begin, and promise as little as possible in return.
I'm developing a finance (asset pricing, etc.) framework for Python. Question: when designing the API for the framework, what factors should I consider when I assess the tradeoff between being strict and being liberal re: inputs?
I have the following method that downloads stock prices from Yahoo.
def historical_prices(ticker, start=None, end=None, data='d', convert=True): # Do stuff
For the date arguments (
end), I could:
- Be strict, and only allow a string of ISO format YYYY-mm-dd, or
- Be liberal and accept datetime objects, strings (of specified formats), etc.