On Mon, 22 Jul 2019 16:25:32 -0500, Michael F. Stemper wrote:
> On 22/07/2019 15.58, Chris Angelico wrote:
>> On Tue, Jul 23, 2019 at 6:34 AM Michael F. Stemper
>> wrote:
>>>
[snip]
>>> from datetime import datetime
>>> from time import strftime
>>> timestamp = datetime.now().strftime( "%Y-%
On 22/07/2019 16.00, Stefan Ram wrote:
> "Michael F. Stemper" writes:
>> The first seems a little clunky with its accessing of multiple
>> attributes, but the second has an additional import. Is there
>> any reason to prefer one over the other?
>
> |>>> import datetime
> |>>> datetime.datetime.no
On 2019-07-22 22:41, Grant Edwards wrote:
On 2019-07-22, Michael F. Stemper wrote:
from datetime import datetime
from time import strftime
timestamp = datetime.now().strftime( "%Y-%m-%d %H:%M" )
[...]
Apparently, the strftime() in that last line is not the one that I
explicitly importe
On 2019-07-22, Michael F. Stemper wrote:
>>> from datetime import datetime
>>> from time import strftime
>>> timestamp = datetime.now().strftime( "%Y-%m-%d %H:%M" )
[...]
> Apparently, the strftime() in that last line is not the one that I
> explicitly imported, but a method of datetime.now
On 22/07/2019 15.58, Chris Angelico wrote:
> On Tue, Jul 23, 2019 at 6:34 AM Michael F. Stemper
> wrote:
>>
>> I have some code that generates a time-stamp as follows:
>>
>> from datetime import datetime
>> tt = datetime.now()
>> timestamp = "%4d-%02d-%02d %02d:%02d" % \
>> (tt.year, tt.
On 22 Jul 2019 23:12, Skip Montanaro wrote:
Assuming you're using Python 3, why not use an f-string?
>>> dt = datetime.datetime.now()
>>> dt.strftime("%Y-%m-%d %H:%M")
'2019-07-22 16:10'
>>> f"{dt:%Y-%m-%d %H:%M}"
'2019-07-22 16:10'
===》》 Or if you're running < Python 3.6 (no f strings): form
Assuming you're using Python 3, why not use an f-string?
>>> dt = datetime.datetime.now()
>>> dt.strftime("%Y-%m-%d %H:%M")
'2019-07-22 16:10'
>>> f"{dt:%Y-%m-%d %H:%M}"
'2019-07-22 16:10'
Skip
--
https://mail.python.org/mailman/listinfo/python-list
On Tue, Jul 23, 2019 at 6:34 AM Michael F. Stemper
wrote:
>
> I have some code that generates a time-stamp as follows:
>
> from datetime import datetime
> tt = datetime.now()
> timestamp = "%4d-%02d-%02d %02d:%02d" % \
> (tt.year, tt.month, tt.day, tt.hour, tt.minute)
>
> I later realize
I have some code that generates a time-stamp as follows:
from datetime import datetime
tt = datetime.now()
timestamp = "%4d-%02d-%02d %02d:%02d" % \
(tt.year, tt.month, tt.day, tt.hour, tt.minute)
I later realized that I could have written it as:
from datetime import datetime
from