Skip to main content

🔄 NOYTHP — Python 倒着写

Project description

🔄 NOYTHP

Python 倒着写。

每个关键字都反转:printtnirpdeffedreturnnruter

tnirp("llehs emosewA")
tnirp("nohtyp esrever si NOYTHP")

安装

pip install noythp

用法

方式一:写 .noythp 文件

hello.noythp

# 所有关键字倒着写!
fed mooT(name):
    tnirp("olleH, " + name)
    nruter name

在 Python 里 import:

import noythp      # 加载运行时
import hello       # 自动找 hello.noythp

hello.mooT("world")  # → "olleH, world"

方式二:直接转译

import noythp

code = noythp.transpile('tnirp("!nohtyp esrever")')
exec(code)

方式三:命令行

python -m noythp hello.noythp

关键字映射

Python     →  NOYTHP
───────        ──────
def            fed
return         nruter
if             fi
else           esle
elif           fi-ekorb  # cool points
for            rof
in             ni
while          elihw
True           eurT
False          eslaF
None           enoN
class          ssalc
self           fles
try            yrt
except         tpecex
finally        yllanif
raise          esiar
continue       enituoc
break          kaerb
import         tropmi
from           morf
as             sa
and            dna
or             ro
not            ton
is             si
pass           ssap
with           htiw
yield          dleiy
global         labolg
lambda         adbmal

内置函数映射

print    →  tnirp
range    →  egnar
len      →  nel
int      →  tni
float    →  taolf
str      →  rts
list     →  tsil
dict     →  tcid
input    →  tupni
sorted   →  detros
max      →  xam
min      →  nim
sum      →  mus
abs      →  sba
append   →  dneppa

完整示例

# 猜数字游戏
fed ssaGuG():
    tupni("rebmun a ssaGuG :")
    tropmi mhtirogla
    tegGuG = tni(tupni())
    fi tegGuG == 42:
        tnirp("!tcerroC")
        kaerb
    esle:
        tnirp("!gnorW")

注意

  • 变量名不要用反转关键字(nitonrosi 等会被转译)
  • 字符串内容正常写,不受影响
  • 扩展名:.noythp.phty

原理

Import Hook 拦截模块加载 → 反转关键字替换 → 生成标准 Python → 执行。纯 Python,零依赖。

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

noythp-0.2.0.tar.gz (7.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

noythp-0.2.0-py3-none-any.whl (7.5 kB view details)

Uploaded Python 3

File details

Details for the file noythp-0.2.0.tar.gz.

File metadata

  • Download URL: noythp-0.2.0.tar.gz
  • Upload date:
  • Size: 7.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.0

File hashes

Hashes for noythp-0.2.0.tar.gz
Algorithm Hash digest
SHA256 34946b3981af570417a0d52e64b0bc21448af34f17d11bad5b81a098bc309f62
MD5 ade5283ed09191f0a6874309daa028d5
BLAKE2b-256 1fb93e94eb518184d22cc18507cbede6415a65ee63e333579cd15553e5c4b8ae

See more details on using hashes here.

File details

Details for the file noythp-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: noythp-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 7.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.0

File hashes

Hashes for noythp-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 665488c52e209cd101a1456f3f2ebeca6813abb0d539ad0ebd978e7006a8eb93
MD5 8b9a503fd940e9741253657dab32974c
BLAKE2b-256 1f804aafc0fbe8e88322ad97cf1a8da77ac98f7a79168378fca28e12c1e183d4

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page