language support
| Area | Implemented |
|---|---|
| Control flow | Conditionals, short-circuit expressions, conditional expressions, chained comparisons, for, while, loop else, break, continue, comprehensions, match with value, sequence, mapping, and class patterns |
| Functions | Recursion, closures, lambdas, decorators, evaluated and postponed annotations, global, nonlocal, defaults, positional-only and keyword-only arguments, *args, **kwargs, and call unpacking |
| Classes | Instance attributes, bound methods, constructors, class and static methods, multiple inheritance with C3 method resolution, dynamic class construction, qualified names, super(), property setters and deleters, descriptors, arithmetic hooks, runtime attribute names, and user-defined iterators |
| Numbers and text | Exact large integers, modular pow, divmod, bit counts, integer bases and formatting, binary64 floats, complex literals and arithmetic, Unicode strings, bytes, codecs, negative indexing, stepped slicing, scalar f-strings |
| Input and output | Scratch keyboard prompts, embedded UTF-8 test input, sys.stdin and sys.stdout, print() through the output list |
| Collections | Lists, tuples, sets, dictionaries, case-sensitive string keys, tuple keys and ordering, named tuples, stable sorted and list.sort, min and max with keys |
| Exceptions and cleanup | try / except / else / finally, custom exception subclasses, raise, assert, and context managers |
| Generators | yield, yield from, generator expressions, next, send, throw, and close |
| Imports | Local .py modules and packages, relative imports, module caching, and the bundled modules above |
| Runtime | Shared interpreter, compact opcode and string tables, reusable stack cells, heap collection, and source file and line on unhandled runtime errors |
The runtime stores integers beyond Scratch’s native range as exact decimal strings. Large calculations take more time and memory. Integer division with /, floating-point formatting, and math functions can differ from CPython at rounding boundaries. The direct-block --native mode uses Scratch’s native numbers. Some details such as exception text, set iteration order, and object representations can differ. For explicit generator cleanup, call close(). Context managers receive None in the traceback slot.
Scratch projects have limited access to host files, networking, subprocesses, native extensions, and other operating system features. Async, arbitrary metaclasses, and full descriptor semantics remain unsupported. Floating-point operations use Scratch doubles. List indexing and dictionary lookup can take work proportional to the container size. The package resolver expects local source files under the entry script's directory. Scratch’s project parser removes the literal backspace control character (\b), which also limits decoding that character from bytes and JSON.