[Datetime-SIG] pytz vs. PEP 495 Was: PEP-431/495

Ethan Furman ethan at stoneleaf.us
Mon Aug 24 23:32:22 CEST 2015

On 08/24/2015 02:10 PM, Alexander Belopolsky wrote:

> I addressed three reasons why people want to have the third value for the fold
>  index in the recent version of the PEP.  Let me just note that the three reasons
> are mutually exclusive: for example, the first and last call for different defaults.
> I suggest that the proponents of the fold=None/fold=-1 option first agree on one
> specific behavior that they want and then we consider the virtues of such behavior
>  (if any).

 From the PEP:

> Moreover, raising an error in the problem cases is only one of many possible
>  solutions. An interactive program can ask the user for additional input, while
>  a server process may log a warning and take an appropriate default action. We
>  cannot possibly provide functions for all possible user requirements, but this
> PEP provides the means to implement any desired behavior in a few lines of code.

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:

# interactive program
except AmbiguousTimeError, NonExistentTimeError:

# server program
except AmbiguousTimeError, NonExistentTimeError:


More information about the Datetime-SIG mailing list