As little as I like exceptions for flow control, you could also do

    try:    
      return uuid.UUID(string).bytes
    catch ValueError:
      return string

Which means the validation is done by the UUID library (which is more guaranteed to get it right in all cases).