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 >> <michael.stem...@gmail.com> wrote: >>> [snip] >>> from datetime import datetime >>> from time import strftime >>> timestamp = datetime.now().strftime( "%Y-%m-%d %H:%M" ) [snip] >> >> What's the second import doing though? You never use strftime. > > Cleaned my contacts, cleaned my readers. Still see strftime() in the > third line. Tried to run the code without the second line. It ran > without complaint. > > Apparently, the strftime() in that last line is not the one that I > explicitly imported, but a method of datetime.now(). Did I get that > right?
Yes, you got that right. The statement datetime.now().strftime("...") says that datetime.now will return an object that has a method named strftime, and calling that method is the next thing to be done. Other things that happen to be lying around named strftime just have no part in the conversation. -- To email me, substitute nowhere->runbox, invalid->com. -- https://mail.python.org/mailman/listinfo/python-list