[Python-checkins] gh-98378: Add small format string example to strftime comments (GH-98379)
miss-islington
webhook-mailer at python.org
Tue Oct 18 09:42:16 EDT 2022
https://github.com/python/cpython/commit/6ccca69d0d313135b2fbb2aa92c69c315be779c6
commit: 6ccca69d0d313135b2fbb2aa92c69c315be779c6
branch: main
author: Alex Zvorygin <grafetu at gmail.com>
committer: miss-islington <31488909+miss-islington at users.noreply.github.com>
date: 2022-10-18T06:42:10-07:00
summary:
gh-98378: Add small format string example to strftime comments (GH-98379)
A small example of what a full date and time would look like would help a lot of developers who may not realize that they should investigate `time.h`'s `strftime`, run `man strftime`, or click through a series of docs on the python docs before they get to the actual [definition here](https://docs.python.org/3/library/datetime.html#strftime-and-strptime-format-codes) which still doesn't have an obvious copy-pastable example of "what the heck format does this thing actually expect?".
Automerge-Triggered-By: GH:rhettinger
files:
M Lib/datetime.py
diff --git a/Lib/datetime.py b/Lib/datetime.py
index 007114ae6220..01742680a95b 100644
--- a/Lib/datetime.py
+++ b/Lib/datetime.py
@@ -1033,7 +1033,11 @@ def ctime(self):
self._day, self._year)
def strftime(self, fmt):
- "Format using strftime()."
+ """
+ Format using strftime().
+
+ Example: "%d/%m/%Y, %H:%M:%S"
+ """
return _wrap_strftime(self, fmt, self.timetuple())
def __format__(self, fmt):
More information about the Python-checkins
mailing list