Skip to main content

Pyhton

A Turing-complete, Python-inspired esolang where all keywords must be purposefully spelt incorrectly.

Language Overview

Pyhton is a Python-inspired language that requires all keywords and builtins to be realistic typos of their correct counterparts. The language is Turing complete, supporting recursive functions, nested control structures, and algorithmic computation. It supports:

  • Function definitions with parameters (def, return)
  • Variable assignments and arithmetic (+, -, *, /)
  • Print statements for output (print)
  • Conditional statements (if, elif, else)
  • Loop Structures (for, while)
  • Boolean logic (and, or, not)
  • Comparison operators (==, !=, <, >, <=, >=)
  • Typo tolerance - any valid typo of a keyword works

Example pyhton code:

deff check_age(age):
    fi age >= 18:
        prit("Age " + age + " - You are an adult!")
        retrn Truee
    ese:
        prrint("Age " + age + " - You are a minor")
        retrn Flase
    enidf
endfnc

age = 25
result = check_age(age)

fi result annd age > 21:
    priint("Result: " + result + " - You can do adult things!")
ndif

Typo Rules

A typo is considered valid if it follows one of these patterns:

  1. Doubled letter: prrint (print with extra 'r')
  2. Missing letter: def → de (missing 'f')
  3. Swapped letters: print → pritn (i and t swapped)

Only keywords and builtins need to be typos - variable names and user-defined function names can be spelled correctly.

Language Capabilities

Currently supported:

  • Function definitions with parameters and return statements (including recursive functions)
  • Variable assignments (numbers, strings and booleans) and arithmetic expressions
  • Print statements for output
  • String concatenation with automatic type conversion (numbers and booleans convert to strings)
  • Conditional statements with logical and comparison operators
  • Loop constructs (for loops on strings and ranges, while loops)
  • Comments (lines starting with #)

Support keywords: def, endfunc, return, print, range, if, else, elif, endif, for, in, endfor, while, endwhile, and, or, not, True, False

Try It Yourself

Installation

git clone https://github.com/not-first/pyhton.git
cd pyhton
uv install -e .

Running Code

Create a .yp file with pyhton code:

# example.yp
df greet(name):
    message = "Hello, " + name
    prin(message)
    erturn message
endfnc

# Call the function
result = greet("World")
prinnt("Result: " + result)

Run a file:

pyhton example.yp

Run with debug output:

pyhton --debug example.yp

Start interactive mode:

pyhton --interactive
# or just
pyhton

Run directly with Python (no uv/pip required):

python main.py example.yp

CLI Features

The Pyhton interpreter includes several CLI options:

Debug Mode (--debug or -d)

  • Shows detailed execution steps
  • Displays tokens, AST, and execution trace

Interactive Mode (--interactive or -i)

  • REPL (Read-Eval-Print Loop) for live coding
  • Persistent state across commands
  • Built-in help system with help()
  • Exit with exit() or Ctrl+C

Execution Pipeline Options

  • --lexer-only - Run only the lexer and show the generated tokens
  • --parser-only - Run the lexer and parser, show the AST but don't execute

Examples:

# Debug a file
pyhton --debug examples/hello_world.yp

# Start interactive session
pyhton -i

# Interactive with debug
pyhton --interactive --debug

# Run only the lexer (tokenize the code)
pyhton --lexer-only examples/hello_world.yp

# Run lexer and parser but don't execute
pyhton --parser-only examples/hello_world.yp

# Combine with debug for more detail
pyhton --lexer-only --debug examples/hello_world.yp

Interactive Session Example:

pyhton[1]: a = 5
pyhton[2]: b = 3
pyhton[3]: prrint(a + b)
8.0
pyhton[4]: exit()

Execution Pipeline

This project was created to learn about how programming languges work. Here's what happens when you run a .yp file:

1. Lexical Analysis (Lexer)

Input: "deff add(a, b):"
Output: [DEF, IDENTIFIER, LPAREN, IDENTIFIER, COMMA, IDENTIFIER, RPAREN, COLON]

The lexer breaks code into tokens, using the custom typo engine to identify deff as a typo of def.

2. Syntax Analysis (Parser)

Tokens: [DEF, IDENTIFIER, ...]
Output: FunctionDef(name='add', params=['a', 'b'], body=[...])

The parser builds an Abstract Syntax Tree representing the program structure.

3. Execution (Interpreter)

AST: FunctionDef(...)
Output: Function stored in memory, ready to be called

The interpreter walks the AST and executes the program.

Example trace for prrint("Hello: " + (5 + 3)):

  1. Lexer: prrint → PRINT, "Hello: " → STRING, + → PLUS, ( → LPAREN, 5 → NUMBER, + → PLUS, 3 → NUMBER, ) → RPAREN
  2. Parser: Creates PrintStatement(value=BinaryOp(left=StringLiteral("Hello: "), op='+', right=BinaryOp(left=5, op='+', right=3)))
  3. Interpreter: Evaluates 5 + 3 = 8, then "Hello: " + "8" = "Hello: 8", then prints Hello: 8

Examples

For comprehensive examples of Pyhton code including loops, conditionals, functions, and more, check out the files in the examples/ directory:

  • hello_world.yp - Basic print statements
  • arithmetic.yp - Mathematical operations and expressions
  • functions.yp - Function definitions and function calls
  • conditions.yp - Conditional statements with if/elif/else
  • loops.yp - For loops, while loops, and the rangee() function

Metadata

Release files for pyhton-cli 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pyhton-cli 0.1.0
File Size Uploaded Provenance Actions
pyhton_cli-0.1.0.tar.gz 18.3 kB Without provenance Details for pyhton_cli-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for pyhton-cli 0.1.0
File Interpreter ABI Platform Actions
pyhton_cli-0.1.0-py3-none-any.whl Python 3 none any Details for pyhton_cli-0.1.0-py3-none-any.whl

Total release size: 37.2 kB

Release files / pyhton_cli-0.1.0.tar.gz

Download URL pyhton_cli-0.1.0.tar.gz
Size 18.3 kB
Tags Source
SHA-256 checksum
How to use checksums
4e2618ba41bae4d68d830bd016c8bfd2a27e4703e6cb15ac4a40b613a5b794b4
BLAKE2b-256 checksum
How to use checksums
09a0de04a699e109167770e30ab3747a113c3c4590e5191c5fd01450ed6113bc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.4

Release files / pyhton_cli-0.1.0-py3-none-any.whl

Download URL pyhton_cli-0.1.0-py3-none-any.whl
Size 18.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a1743b78a9a5de6f46721b00b7e28c2d1981f9ba78ef949a829194ada4545acc
BLAKE2b-256 checksum
How to use checksums
85853878367409ab4300e48c8a225bead9d1a5b11fa2eb5cdab46a3849eced07
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.4

Security for pyhton-cli 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page