Is there a conflict of libraries here?

Peter Pearson pkpearson at nowhere.invalid
Fri Nov 6 10:35:55 EST 2020


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.


More information about the Python-list mailing list

AltStyle によって変換されたページ (->オリジナル) /