Author adamwill
Recipients Daniel.O'Connor, adamwill, akira, belopolsky, bignose, mumino, r.david.murray, rbcollins, santoso.wijaya, shanmbic, tim.peters, vstinner
Date 2018-03-03.01:50:05
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1520041806.99.0.467229070634.issue12750@psf.upfronthosting.co.za>
In-reply-to
Content
On the "attractive nuisance" angle: I just ran right into this problem, and reported https://bugs.python.org/issue32988 .

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.
History
Date User Action Args
2018-03-03 01:50:07adamwillsetrecipients: + adamwill, tim.peters, belopolsky, vstinner, rbcollins, r.david.murray, santoso.wijaya, akira, bignose, Daniel.O'Connor, mumino, shanmbic
2018-03-03 01:50:06adamwillsetmessageid: <1520041806.99.0.467229070634.issue12750@psf.upfronthosting.co.za>
2018-03-03 01:50:06adamwilllinkissue12750 messages
2018-03-03 01:50:05adamwillcreate