[Python-Dev] Method signatures in the datetime module documentation

Alexander Belopolsky alexander.belopolsky at gmail.com
Fri Jul 29 12:55:41 EDT 2016


I have started [1] writing documentation for the new PEP 495 (Local
Time Disambiguation) features and ran into the following problem.  The
current documentation is rather inconsistent in presenting the method
signatures.  For example:

date.replace(year, month, day) [2], but
datetime.replace([year[, month[, day[, hour[, minute[, second[,
microsecond[, tzinfo]]]]]]]]) [3].


The new signature for datetime.replace in the Python implementation is

def replace(self, hour=None, minute=None, second=None, microsecond=None,
            tzinfo=True, *, fold=None):


but the C implementation does not accept True for tzinfo or None for
the other arguments.  The defaults in the Python implementation are
really just sentinels to detect which arguments are not provided.

How should I present the signature of the new replace method in the
documentation?


[1]: http://bugs.python.org/issue27595
[2]: https://docs.python.org/3/library/datetime.html#datetime.date.replace
[3]: https://docs.python.org/3/library/datetime.html#datetime.datetime.replace


More information about the Python-Dev mailing list