classification
Title: Standard Color class
Type: enhancement Stage: resolved
Components: Library (Lib) Versions:
process
Status: closed Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: eric.smith, mertcandav, rhettinger
Priority: normal Keywords: patch

Created on 2020-09-14 16:44 by mertcandav, last changed 2020-09-18 07:58 by mertcandav. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 22241 closed mertcandav, 2020-09-14 20:07
Messages (5)
msg376883 - (view) Author: Mertcan (mertcandav) * Date: 2020-09-14 16:44
I think it would be useful to have a Color class in Python. Thus, it can become a standard and additional libraries may not be needed for many operations. Many libraries can be built around this Color class and can pave the way for many innovations. It can be a good advantage, especially in the GUI area, that beautiful libraries have a common data type. Thanks!
msg376906 - (view) Author: Eric V. Smith (eric.smith) * (Python committer) Date: 2020-09-14 21:00
The normal way for something like this to be added to the stdlib would first be for a version on PyPI to be widely used. Then it would be evaluated for suitability for inclusion in the stdlib.

Having it first on PyPI would flesh out the API and use cases. For example, I have no idea what an API for a Color class would be. I imagine it would depend on what other software it's designed to interface with. Would it be float values? ints? What range? RGB? HSV? Conversions between those?

For example, see the process that ipaddress went through, which included writing PEP 3144.
msg376909 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2020-09-14 21:39
Also the trend is to not put classes like this in the standard library at all.
msg376916 - (view) Author: Eric V. Smith (eric.smith) * (Python committer) Date: 2020-09-14 23:27
Yeah, I don't want to give any false hope on getting such a class accepted to the stdlib. It's not super likely to be accepted unless there's a more compelling motivation on why it needs to be in the stdlib and not just on PyPI.
msg376929 - (view) Author: Mertcan (mertcandav) * Date: 2020-09-15 07:39
For example, consider the libraries of stdlib and PyPI that are available now and may be in the future. In libraries like Tkinter or Turtle, a universal color class can make the code clearer. Color operations can also be performed by representing the Color class. For example, deriving a CLI color code from the RGB values ​​it represents. Doesn't such a thing provide more advanced possibilities for the existing cli library (cmd) and reduce the need for PyPI API?

I think this can provide a common use for WEB and GUI libraries. It can also be beneficial in terms of performance as it can reduce the number of parameters for most functions.

Python is a programming language widely used as CLI. With a built-in color library, wouldn't we increase the appeal and language coverage? I see that there are many libraries on PyPI regarding colors, and most of them are built on CLI. Some of these are really used too much.

We often encounter issues like "How can I print in color in Console?" in places like Stackoverflow.

I think that many color-related or color libraries do not have a color class on stlib, so it might be too crowded for them to make a color class for themselves, especially when using multiple color-oriented libraries. Even if they don't make a special class for them, the number of parameters will naturally be higher. However, I think a standard color class can prevent all of these and increase readability.
History
Date User Action Args
2020-09-18 07:58:02mertcandavsetstatus: open -> closed
stage: patch review -> resolved
2020-09-15 07:39:31mertcandavsetmessages: + msg376929
2020-09-14 23:27:46eric.smithsetmessages: + msg376916
2020-09-14 21:39:14rhettingersetnosy: + rhettinger
messages: + msg376909
2020-09-14 21:00:41eric.smithsetnosy: + eric.smith
messages: + msg376906
2020-09-14 20:07:04mertcandavsetkeywords: + patch
stage: patch review
pull_requests: + pull_request21302
2020-09-14 16:44:39mertcandavcreate