Zooko O'Whielacronx added the comment:
Thank you for the one-liner. I was about to use it in the allmydata.org
project, but I remembered that my programming partner would probably
prefer the larger but more explicit if:else: over the clever one-liner.
Perhaps it will be useful to someone else.
Skip Montanaro added the comment:
Zooko> I meant that it special-cases .microseconds == 0.
Tim indicated in his comment that the behavior is both by design and
documented and isn't going to change. In an earlier comment I showed how to
achieve the result you ased for in one line. Here's anothe
Zooko O'Whielacronx added the comment:
I meant that it special-cases .microseconds == 0. If I want to produce
a custom output format using Python Standard Library, I expect to have
to slice, add my own fields and so forth, but I don't expect to need an
"if" to handle a special-case that is there
Skip Montanaro added the comment:
Zooko> Here is a note for the next person who comes to this ticket
Zooko> wondering why isoformat() exhibits this slightly un-Pythonic
Zooko> behavior.
What are you referring to, that it doesn't display any microseconds when the
microsecond field happens
Zooko O'Whielacronx added the comment:
Here is a note for the next person who comes to this ticket wondering
why isoformat() exhibits this slightly un-Pythonic behavior. If you
want to use isoformat() to produce, for example, timestamps for your
logfiles, you'll need to do something like the fol
Skip Montanaro added the comment:
I'm going to offer one more argument here, then close the ticket.
(Tim already told you the behavior wasn't going to change.)
str() is a convenience function intended to give conveniently
human-readable output. It's not intended to be a one-size-fits-
all routin