On Mon, Aug 24, 2015 at 5:32 PM, Ethan Furman <[email protected]> wrote:

> It is my contention that library code (such as datetime) should raise
> exceptions when something exceptional happens, and the program code can
> then handle it appropriately for that program:
>
...

>
> # server program
> try:
>     get_a_datetime_from_somewhere(ltdf=None)
> except AmbiguousTimeError, NonExistentTimeError:
>     log(weird_time_error)
>     use_default()
>

I've been criticized on this list for using python-resembling pseudo-code,
so I will assume that what you show is an actual Python code.  In this
case,  get_a_datetime_from_somewhere and use_default lines have no visible
effect on the program and I have no guess for what they are supposed to do
internally.

I do show in the PEP [1] how a function that raises an error on
ambiguous/missing time can be written.


[1]: https://www.python.org/dev/peps/pep-0495/#strict-invalid-time-checking
_______________________________________________
Datetime-SIG mailing list
[email protected]
https://mail.python.org/mailman/listinfo/datetime-sig
The PSF Code of Conduct applies to this mailing list: 
https://www.python.org/psf/codeofconduct/

Reply via email to