def parse_text(text):
    """Parse code from a string of text."""
    assert isinstance(text, _str_type), "`text` parameter should be a string, got %r" % type(text)
    gen = iter(text.splitlines(True))  # True = keep newlines
    readline = gen.next if hasattr(gen, "next") else gen.__next__
    return Code(_tokenize(readline))
Parse code from a string of text.