Desugar
Unravelling Python source code
Install / Use
/learn @brettcannon/DesugarREADME
desugar
Unravelling Python's syntactic sugar source code.
There are accompanying blog posts to go with all of the code in this repository.
Unravelled syntax
obj.attr➠builtins.getattr(obj, "attr")(includingobject.__getattribute__())a + b➠operator.__add__(a, b)a - b➠operator.__sub__(a, b)a * b➠operator.__mul__(a, b)a @ b➠operator.__matmul__(a, b)a / b➠operator.__truediv__(a, b)a // b➠operator.__floordiv__(a, b)a % b➠operator.__mod__(a, b)a ** b➠operator.__pow__(a, b)a << b➠operator.__lshift__(a, b)a >> b➠operator.__rshift__(a, b)a & b➠operator.__and__(a, b)a ^ b➠operator.__xor__(a, b)a | b➠operator.__or__(a, b)a += b➠a = operator.__iadd__(a, b)a -= b➠a = operator.__isub__(a, b)a *= b➠a = operator.__imul__(a, b)a @= b➠a = operator.__imatmul__(a, b)a /= b➠a = operator.__itruediv__(a, b)a //= b➠a = operator.__ifloordiv__(a, b)a %= b➠a = operator.__imod__(a, b)a **= b➠a = operator.__ipow__(a, b)a <<= b➠a = operator.__ilshift__(a, b)a >>= b➠a = operator.__irshift__(a, b)a &= b➠a = operator.__iand__(a, b)a ^= b➠a = operator.__ixor__(a, b)a |= b➠a = operator.__ior__(a, b)~ a➠operator.__invert__(a)- a➠operator.__neg__(a)+ a➠operator.__pos__(a)a == b➠operator.__eq__(a, b)(includingobject.__eq__())a != b➠operator.__ne__(a, b)(includingobject.__ne__())a < b➠operator.__lt__(a, b)a <= b➠operator.__le__(a, b)a > b➠operator.__gt__(a, b)a >= b➠operator.__ge__(a, b)a is b➠operator.is_(a, b)a is not b➠operator.is_not(a, b)not a➠operator.not_(a)a in b➠operator.__contains__(b, a)a not in b➠operator.not_(operator.__contains__(b, a))a or b➠_temp if (_temp := a) else ba and b➠_temp if not (_temp := a) else bimport a.b➠a = __import__('a.b', globals(), locals())import a.b as c➠c = __import__('a', globals(), locals(), ['b'], 0).bfrom .a import b➠b = __import__('a', globals(), locals(), ['b'], 1).bfrom .a import b as c➠c = __import__('a', globals(), locals(), ['b'], 1).bassert ...➠ see below (post)for ...➠ see below (includingbuiltins.iter()andbuiltins.next())pass➠"pass"with ...➠ see below (post)- [
async def ...](https://docs.python.org/3.8/reference/compound_stmts.html#coroutine-function-defi
Related Skills
node-connect
350.8kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
110.4kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
350.8kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
qqbot-media
350.8kQQBot 富媒体收发能力。使用 <qqmedia> 标签,系统根据文件扩展名自动识别类型(图片/语音/视频/文件)。
