code: def getsource(obj):
      
      try:
          try:
              src = to_text_string(inspect.getsource(obj))
          except TypeError:
              if hasattr(obj, '__class__'):
                  src = to_text_string(inspect.getsource(obj.__class__))
              else:
                  # Bindings like VTK or ITK require this case
                  src = getdoc(obj)
          return src
      except (TypeError, IOError):
          return
docs: Wrapper around inspect.getsource