Skip to content

python feature support_us

Tki_sor edited this page Nov 12, 2026 · 1 revision

English · 中文

Python feature support

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.

Summary

  • Works: the walrus operator :=, match / case (some patterns), and type annotations (including int | str, list[int] and Self; all are ignored).
  • Doesn't work: async / await, positional-only / and keyword-only * parameters, except*, the type statement and [T] generic syntax, t-strings, and dict merge |.
  • There is no Python standard library, so modules such as typing, asyncio and tomllib can't be imported. You can write Self or List in annotations, but don't write from typing import ....

Python 3.8

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

Python 3.9

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

Python 3.10

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:

Python 3.11

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

Python 3.12

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

Python 3.13

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

Python 3.14

Feature Example Status Notes
Template strings (t-strings) t'hello {name}' No Parse error
Deferred evaluation of annotations N/A NekoJS ignores annotations anyway

Older syntax that doesn't work

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.

References


Previous: Python scripts · Contents · Next: Event reference

NekoJS Wiki

中文 · English

先看这里 / Start here

  • 首页 / Home · 中文 · EN
  • 平台与兼容性 / Platforms and compatibility · 中文 · EN
  • 快速开始 / Quick start · 中文 · EN
  • 配置参考 / Configuration · 中文 · EN
  • 常见问题 / FAQ · 中文 · EN

脚本作者 / Script authors

  • 脚本基础 / 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

整合包作者 / Modpack authors

  • 版本化脚本包 / 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

插件开发者 / Plugin developers

  • 插件开发 / Plugin development · 中文 · EN
  • 类型适配器 / Type adapters · 中文 · EN
  • 事件扩展 / Event extensions · 中文 · EN
  • 注解体系 / Annotations · 中文 · EN

项目贡献者 / Project contributors

  • 项目架构 / Project architecture · 中文 · EN
  • Probe 类型生成 / Probe type generation · 中文 · EN
  • 构建系统 / Build system · 中文 · EN

Clone this wiki locally