On 11/8/2020 9:56 AM, Chris Angelico wrote:
On Mon, Nov 9, 2020 at 1:11 AM Terry Reedy <tjre...@udel.edu> wrote:

A module containing an object with the same name as the module is a real
pain, a constant mental papercut.  I consider datetime.datetime to be a
design mistake*.  You are the 2nd person in about a month to post the
same resulting code problem.

* Either the class should have been 'Datetime', capitalized like classes
in modules other that builtins generally should be, or the module should
have been given a different name.  I personally would always rename the
module when imported.


Yes, it's annoying, but it's only annoying when code on the internet
suggests "from datetime import *",

I agree that the latter is annoying, but I disagree about 'only'. Names pointing to two different objects (or people ;-) are ambiguous without additional disambiguation. If I write 'datetime has an off-by-one bug' or 'datetime is great', which datetime do I mean?

idlelib once had multiple name.name pairs, such as Debugger.Debugger, and to me, the nuisance of fixing them (as per PEP 434 and subsequent decision by the BDFL-delegate) has now been outweighed by the continuing benefit.


--
Terry Jan Reedy

--
https://mail.python.org/mailman/listinfo/python-list

Reply via email to