Author v kats
Recipients docs@python, v kats
Date 2018-07-27.15:07:15
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1532704035.87.0.56676864532.issue34249@psf.upfronthosting.co.za>
In-reply-to
Content
Section "strftime() and strptime() Behavior" says:

"The full set of format codes supported varies across platforms, because Python calls the platform C library’s strftime() function, and platform variations are common. To see the full set of format codes supported on your platform, consult the strftime(3) documentation."

It implies that this applies for strftime only, and indeed it refers to C library’s strftime().

However, it's easy to miss (at least I got confused and lost some time), so I propose to clarify the paragraph.

strptime and %s

# python
Python 2.7.6 (default, Nov 23 2017, 15:49:48) 
[GCC 4.8.4] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from datetime import datetime
>>> datetime.strptime('1532689414','%s')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>


strftime and %s

python
Python 2.7.6 (default, Nov 23 2017, 15:49:48) 
[GCC 4.8.4] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from datetime import datetime
>>> datetime.now().strftime('%s')
'1532702817'

  File "/usr/lib/python2.7/_strptime.py", line 317, in _strptime
    (bad_directive, format))
ValueError: 's' is a bad directive in format '%s'
History
Date User Action Args
2018-07-27 15:07:15v katssetrecipients: + v kats, docs@python
2018-07-27 15:07:15v katssetmessageid: <1532704035.87.0.56676864532.issue34249@psf.upfronthosting.co.za>
2018-07-27 15:07:15v katslinkissue34249 messages
2018-07-27 15:07:15v katscreate