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
try:
get_a_datetime_from_user(ltdf=None)
except AmbiguousTimeError, NonExistentTimeError:
get_clarification_from_user()
# server program
try:
get_a_datetime_from_somewhere(ltdf=None)
except AmbiguousTimeError, NonExistentTimeError:
log(weird_time_error)
use_default()
--
~Ethan~
_______________________________________________
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/