Is there a conflict of libraries here?
Steve
Gronicus at SGA.Ninja
Fri Nov 6 17:05:53 EST 2020
"Right, because the name "datetime" points to the class datetime in the
module datetime.
The class, unlike the module, has no "datetime" attribute."
Ok, how do I unpoint/repoint a "datetime" to let the two locations work?
"Apologies if you already knew this. I wasn't sure."
Absolutely did not know any of this.
Libraries are a slow learning process for me....
Footnote
Patient in the hospital: "What happens after I die?"
Doctor: "We clean up the bed and bring in a new patient."
-----Original Message-----
From: Python-list <python-list-bounces+gronicus=sga.ninja at python.org> On
Behalf Of Peter Pearson
Sent: Friday, November 6, 2020 10:36 AM
To: python-list at python.org
Subject: Re: Is there a conflict of libraries here?
On Fri, 6 Nov 2020 02:25:25 -0500, Steve <Gronicus at SGA.Ninja> wrote:
> In my program, I have the following lines of code:
> import random
> import re
> import time
> import datetime
At this point, the name "datetime" points to a module.
> from datetime import timedelta
> from time import gmtime, strftime
> import winsound as ws
> import sys
>
[snip]
>
> from datetime import datetime
By that, you have reassigned the name "datetime" to point to a class defined
in the datetime module.
[snip]
>
> AttributeError: type object 'datetime.datetime' has no attribute
> 'datetime'
Right, because the name "datetime" points to the class datetime in the
module datetime. The class, unlike the module, has no "datetime"
attribute.
Apologies if you already knew this. I wasn't sure.
--
To email me, substitute nowhere->runbox, invalid->com.
--
https://mail.python.org/mailman/listinfo/python-list
More information about the Python-list
mailing list