Is there a conflict of libraries here?
Ethan Furman
ethan at stoneleaf.us
Mon Nov 9 13:24:55 EST 2020
On 11/8/20 9:20 PM, Chris Angelico wrote:
> Perhaps, but certainly the confusion is far less when the module is
> always imported as itself, and then the class is "datetime.datetime"
> which nicely parallels "datetime.date" and "datetime.time".
I find doubled names such as "datetime.datetime" both jarring and visual noise.
Thankfully, we can rename modules on import:
import datetime as dt
import time as t
import PIL.Image as im
As for "from blablah import *" -- that should only be done with modules specifically designed for it; having said that,
it looks like datetime.py was so designed. So, if I had a module making extensive use of the datetime contents, and
wasn't using the time module, I would have no problem with "from datetime import *". On the other hand, if datetime was
only a small portion of my module, I would "import datetime as dt".
--
~Ethan~
More information about the Python-list
mailing list