Skip to content

Language

Not supported

Syntax the compiler rejects up front, with a located error and a hint.

The compiler validates syntax up front and rejects these with a located error and a hint, rather than miscompiling them:

  • Asynchronous generators (an async def that yields, and so an async for over one), asynchronous comprehensions, and an async def inside a function (async def, await, async with, and async for over a class with __aiter__ and __anext__ are supported: see JavaScript and async)
  • match statements, type aliases, except*, and del of an attribute or a stepped slice
  • from module import *
  • A generator expression kept in a variable, returned, stored, or passed to the program's own functions, and print(), len(), or bool() of one: it goes where a builtin, a standard-library call, a for statement, or a comprehension walks it once (see Limitations)
  • A class whose base is a builtin value type (class Stack(list)), an undefined name, or an expression computed when the class statement runs
  • *args, **kwargs, and keyword-only parameters on methods other than __init__, ** unpacking in a call, and positional-only parameters (/)
  • Class keywords other than metaclass= (__init_subclass__ arguments)
  • Decorators CPython does not define (@memoize, @timer, @debug, @pure, @type_check, @default_value, @wasm_export), which CPython rejects with NameError
  • Module-level statements other than definitions. Only definitions run when a module starts: X = 1, X: int = 1, X = helper(), X = ClassName(), def, class, and imports (a try/except ImportError guarded import included). Definitions that are not plain constants are evaluated once, in source order (a module you import, at its first import), when the module is instantiated; one that reads a definition appearing after it is refused, as it is a NameError in CPython. A module-level loop, if, try, bare call statement, augmented assignment, tuple unpacking, or write through a subscript or attribute is rejected, because it would otherwise be compiled away and later reads would see the value from before it. Put the code in a function and call it, or drive it from if __name__ == "__main__":, which is recognized as the entry point
  • Third-party packages: the supported subset is your own modules plus the standard-library modules listed on the Python subset

If you find a program that compiles and answers differently from CPython, other than as listed under Where the answer differs, that is a bug: please report it.