Repository navigation
python feature support_us
Tki_sor edited this page Nov 12, 2026
·
1 revision
English · 中文
This page lists the language features added in recent Python versions (3.8 through 3.14) and whether they work in NekoJS.
NekoJS converts Python code to JavaScript before running it, and supports only part of Python. For everyday syntax (functions, classes, comprehensions, f-strings and so on), see Python scripts. This page answers one question: "I learned this in a recent Python version. Can I use it in NekoJS?"
Status values in the tables:
- Works: write it as usual.
- Partly: works with limits; see the notes.
- No: fails with an error, or gives a wrong result.
- N/A: interpreter, performance or standard library changes that don't affect scripts.
- Works: the walrus operator
:=,match/case(some patterns), and type annotations (includingint | str,list[int]andSelf; all are ignored). - Doesn't work:
async/await, positional-only/and keyword-only*parameters,except*, thetypestatement and[T]generic syntax, t-strings, and dict merge|. - There is no Python standard library, so modules such as
typing,asyncioandtomllibcan't be imported. You can writeSelforListin annotations, but don't writefrom typing import ....
| Feature | Example | Status | Notes |
|---|---|---|---|
| Walrus operator | if (n := len(xs)) > 3: |
Partly | Define the variable with a normal assignment first; see "Known issues" in Python scripts |
| Positional-only parameters | def f(a, /, b): |
No | Parse error |
f-string = for debugging |
f'{x=}' |
No | No error, but only the value is printed, without the x= prefix |
| Feature | Example | Status | Notes |
|---|---|---|---|
| Dict merge operators |
a | b, a |= b
|
No | No error, but the result is wrong. Use {**a, **b}
|
| Built-in generic annotations | x: list[int] = [] |
Works | The annotation is ignored |
str.removeprefix / removesuffix
|
s.removeprefix('a') |
No | Runtime error. Use a slice instead |
| Feature | Example | Status | Notes |
|---|---|---|---|
match / case
|
match x: |
Partly | Literals, _, captures, |, list and dict patterns, keyword class patterns and if guards work. Positional class patterns such as Point(0, 0) don't |
| Union type annotations | def f(x: int | str): |
Works | The annotation is ignored |
| Parenthesized context managers | with (a as x, b as y): |
No | Drop the parentheses: with a as x, b as y:
|
| Feature | Example | Status | Notes |
|---|---|---|---|
| Exception groups | except* ValueError: |
No | Parse error |
| Exception notes | e.add_note('...') |
No | |
Self annotation |
def copy(self) -> Self: |
Works | The annotation is ignored |
asyncio.TaskGroup, tomllib
|
No | No standard library |
| Feature | Example | Status | Notes |
|---|---|---|---|
type statement |
type Pair = tuple[int, int] |
No | Parse error |
| Type parameter syntax | def first[T](xs): |
No | Parse error. Remove [T]
|
| Relaxed f-strings | f"{f"{x}"}" |
Partly | Using the other quote type inside works (f"{'a'}"); nesting the same quote type or writing comments inside {} doesn't |
@override |
@override |
No | Methods accept only @staticmethod, @classmethod and @property
|
| Feature | Example | Status | Notes |
|---|---|---|---|
| Type parameter defaults | class Box[T = int]: |
No | Type parameter syntax itself isn't supported |
@deprecated |
@deprecated('use g') |
No | Decorators can't take arguments |
| New REPL, free-threaded builds | N/A |
| Feature | Example | Status | Notes |
|---|---|---|---|
| Template strings (t-strings) | t'hello {name}' |
No | Parse error |
| Deferred evaluation of annotations | N/A | NekoJS ignores annotations anyway |
These aren't new features, but people often ask about them:
| Syntax | Status | Alternative |
|---|---|---|
async / await, async for, async with
|
No | Use event callbacks |
global / nonlocal
|
No | Keep state in a dict or list |
Starred assignment a, *rest = xs
|
No |
a = xs[0] and rest = xs[1:]
|
str.format |
No | f-strings |
| Multiple base classes | No | Single inheritance or composition |
For the full list of unsupported syntax and alternatives, see Python scripts.
- What's New in Python: official release notes for each version.
- PEP 572 — Assignment expressions (3.8)
- PEP 636 — match/case tutorial (3.10)
- PEP 654 — Exception groups and
except*(3.11) - PEP 695 — Type parameter syntax (3.12)
- PEP 701 — Formalized f-string syntax (3.12)
- PEP 750 — Template strings (3.14)
- 首页 / Home · 中文 · EN
- 平台与兼容性 / Platforms and compatibility · 中文 · EN
- 快速开始 / Quick start · 中文 · EN
- 配置参考 / Configuration · 中文 · EN
- 常见问题 / FAQ · 中文 · EN
- 脚本基础 / Script basics · 中文 · EN
- 脚本 API 约定 / Script API conventions · 中文 · EN
- 脚本属性 / Script properties · 中文 · EN
- 全局绑定 / Global bindings · 中文 · EN
- 数据、状态与持久化 / Data, state and persistence · 中文 · EN
- Python 脚本 / Python scripts · 中文 · EN
- Python 特性清单 / Python feature support · 中文 · EN
- 事件参考 / Event reference · 中文 · EN
- AI 辅助脚本编写 / AI-assisted authoring · 中文 · EN
- 命令 / Commands · 中文 · EN
- 错误与日志参考 / Error and log reference · 中文 · EN
- 客户端绘制与后处理 / Client rendering and post effects · 中文 · EN
- 版本化脚本包 / Versioned script packs · 中文 · EN
- 配方系统 / Recipe system · 中文 · EN
- 注册新内容 / Registering new content · 中文 · EN
- 模块系统 / Module system · 中文 · EN
- TypeScript 与 JSX / TypeScript and JSX · 中文 · EN
- JSX 客户端 UI / JSX client UI · 中文 · EN
- MixinJS(实验性) / MixinJS (experimental) · 中文 · EN
- Node.js 兼容 / Node.js compatibility · 中文 · EN