Color string from object (random if empty, deterministic else)
From PEP 8:


  Comparisons to singletons like None should always be done with is or
  is not, never the equality operators.
  
  Also, beware of writing if x when you really mean if x is not None --
  e.g. when testing whether a variable or argument that defaults to None
  was set to some other value. The other value might have a type (such
  as a container) that could be false in a boolean context!


What you should do in your case is : obj = obj if obj is not None else random().

Then, even though I like the ternary operator, I reckon its usage is not required/idiomatic here. The usual way to handle default parameter is more like

if arg is None:
    arg = default()


As far as I can tell, using hash like you did is ok. However, I guess you should handle values that could be out of the range you are expecting (I couldn't find easily something telling which range of values can be returned).