use uuid (uuid module in python> = 2.5).
This uuid in version 4 is, by definition, random in all fields (except one)
>>> uuid.uuid4()
UUID('9d477dc7-a986-4e3d-aa4f-6e57f690be78')
You can decompose the fields correctly to create a color or name (by matching a bucket of names into a specific field). Of course, you limit your hash (the real identity is always uuid), but for visual purposes this is quite a lot. For example, you can use the first three octets to generate the color # 9d477d, and the remaining octet c7select one name from a set of 256.
If you end up with too ugly colors, you can work in HSV instead, as well as saturation and clip value for given levels. again, this further limits your hash (but the color space is already quite limited).
source
share