Adam Williamson <> added the comment:

On the "attractive nuisance" angle: I just ran right into this problem, and 
reported .

As I suggested there, if Python doesn't try to fix this, I'd suggest it should 
at least *explicitly document* that using %s is unsupported and dangerous in 
more than one way (might not work on all platforms, does not do what it should 
for 'aware' datetimes on platforms where it *does* work). I think explicitly 
telling people NOT to use it would be better than just not mentioning it. At 
least for me, when I saw real code using it and that the docs just didn't 
mention it, my initial thought was "I guess it must be OK, and the docs just 
missed it out for some reason". If I'd gone to the docs and seen an explicit 
note that it's not supported and doesn't work right, that would've been much 
clearer and I wouldn't have had to figure that out for myself :)

For Python 2, btw, the arrow library might be a suitable alternative to 
suggest: you can do something like this, assuming you have an aware datetime 
object called 'awaredate' you want to get the timestamp for:

import arrow
ts = arrow.get(awaredate).timestamp

and it does the right thing.

nosy: +adamwill

Python tracker <>
Python-bugs-list mailing list

Reply via email to