from io import StringIO
import tokenize


def get_comments(source_code):
  """
  :param source_code: Source code as text
  :return: Comments in source code as a list
  """
  io_obj = StringIO(source_code.encode("utf-8"))
  comments = []
  for tok in tokenize.generate_tokens(io_obj.readline):
    token_type = tok[0]
    token_string = tok[1]
    if token_type == tokenize.COMMENT:
      comments.append(token_string.replace("#", " ").strip())
  return comments