public class PythonTokenizer extends CodeTokenizer
Specialized CodeTokenizer for Python source files (.py, .pyw, .pyi).
Supports Python # comments, single/double and triple-quoted strings ("""...""", '''...'''), f/r/b/u string prefixes with {...} interpolation, and @decorator lines.
import klyn.code
import klyn.code.python
tokenizer = PythonTokenizer()
res = tokenizer.tokenizeLine("def greet(name: str) -> str: # hello")
assert res.spans[0].kind == TokenKind.KEYWORD
assert res.spans[2].kind == TokenKind.DECLARATION_NAME| Modifier and Type | Member | Description |
|---|---|---|
| public | PythonTokenizer | Constructs a PythonTokenizer configured with PythonLanguage.profile(). |