[Datetime-SIG] pytz vs. PEP 495 Was: PEP-431/495
Alexander Belopolsky
alexander.belopolsky at gmail.com
Mon Aug 24 23:45:50 CEST 2015
On Mon, Aug 24, 2015 at 5:32 PM, Ethan Furman <ethan at stoneleaf.us> 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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/datetime-sig/attachments/20150824/dc396b13/attachment.html>
More information about the Datetime-SIG
mailing list