code: def pattern_to_str(pattern):
      
      if isinstance(pattern, str):
          return repr(pattern)
      else:
          return repr(pattern.pattern) if pattern else None
docs: Convert regex pattern to string.
  
      If pattern is string it returns itself,
      if pattern is SRE_Pattern then return pattern attribute
      :param pattern: pattern object or string
      :return: str: pattern sttring