Skip to content

Commit

Permalink
Simplify the gray/grey FAQ entry.
Browse files Browse the repository at this point in the history
There was a concern about Python dictionary ordering, once upon a
time, but it isn't a problem now: the only issue is ensuring that
the behavior is consistent and predictable, which still does require
explicitly picking one or the other.
  • Loading branch information
ubernostrum committed May 22, 2024
1 parent 66144db commit 71d0256
Showing 1 changed file with 4 additions and 10 deletions.
14 changes: 4 additions & 10 deletions docs/faq.rst
Original file line number Diff line number Diff line change
Expand Up @@ -58,16 +58,10 @@ Using any of the conversions from names to other formats
:func:`~webcolors.name_to_rgb_percent`) will accept either spelling provided
the `spec` argument is :data:`~webcolors.CSS3`.

However, converting from other formats to a name requires picking one of these
spellings. Since ``webcolors`` uses a Python :class:`dict` to store its
:ref:`name-to-value mappings <mapping-constants>`, simply reversing those
mappings risks inconsistency: swapping the keys and values of a :class:`dict`
in Python depends on the key order, which varies from one version of Python to
another and in several supported Python versions is not guaranteed to be
consistent and/or is documented as an implementation detail not to be relied
on. So ``webcolors`` must manually pick a spelling to normalize to, and chooses
`gray`. This choice was made for consistency with HTML 4, CSS1, and CSS2, each
of which only allowed `gray`.
However, converting from other formats to a name requires choosing which
spelling to return, and should return the same choice each time. So
``webcolors`` chooses the ``gray`` variants, for consistency with HTML 4, CSS1,
and CSS2, each of which only allowed `gray`.


Why aren't HSL values supported?
Expand Down

0 comments on commit 71d0256

Please sign in to comment.