On Tue, Jan 26, 2021 at 12:44 AM Steven D'Aprano <st...@pearwood.info> wrote:
>
> On Mon, Jan 25, 2021 at 06:17:09PM +0100, Victor Stinner wrote:
> > Hi Bernat,
> >
> > "stdlib_module_names" was my first idea but it looks too long, so I
> > chose "module_names". But someone on Twitter and now you asked me why
> > not "stdlib_module_names", so I wrote a PR to rename module_names to
> > sys.stdlib_module_names:
> > https://github.com/python/cpython/pull/24332
> >
> > At least "stdlib_module_names" better summarizes its definition: "A
> > frozenset of strings containing the names of standard library
> > modules".
>
> Your first instinct that it is too long is correct. Just call it
> "stdlib" or "stdlib_names". The fact that it is a frozen set of module
> names will be obvious from just looking at it, and there is no need for
> the name to explain everything about it. We have:

The sys module already has a sys.modules attribute, and so
sys.module_names sounds like "give me the name of all imported
modules": sys.module.keys(). It's confusing. Just after I announced
the creation of the attribute, at least 3 people told me that they
were confused by the name. Also, my PR was approved quickly 3 times
which confirms that the rename was a good idea ;-)

In general, I agree that short names are great ;-) For example, I like
short obj.name() rather than obj.getname() when it doesn't make sense
to set the name.

Naming is a hard problem :-D

Victor
-- 
Night gathers, and now my watch begins. It shall not end until my death.
_______________________________________________
Python-Dev mailing list -- python-dev@python.org
To unsubscribe send an email to python-dev-le...@python.org
https://mail.python.org/mailman3/lists/python-dev.python.org/
Message archived at 
https://mail.python.org/archives/list/python-dev@python.org/message/DKRUV2HDWIN4XWDNXT55BBHNQOUZTOU6/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to