Phyton (Greek Ξ¦Ο ΟΟΞ½ for "plant") is a Python interpreter that accepts multiple spellings of keywords, designed to confuse bad spellers!
Inspired by a suggestion from Michael A. Covington, author of Natural Language Processing for Prolog Programmers π
- Accepts common misspellings of Python keywords
- Interactive REPL mode
- File execution mode
- Friendly error messages
- Fuzzy matching for unknown misspellings (optional)
- Supports creative variations like
prinforprint,defffordef, etc.
defβdeff,define,definifβiff,iifelifβelsif,elseif,else_ifelseβels,elzeforβfore,four,frwhileβwile,whyle,whilinβinn,iinreturnβretrun,retrn,retimportβimprt,imort,importtfromβfrm,fomasβaz,assclassβclas,clss,klasstryβtri,tyrexceptβexept,excpt,catchfinallyβfinaly,finalewithβwth,witandβandd,adn,&orβorr,|notβnott,no,!
Trueβtrue,TRUE,truFalseβfalse,FALSE,falsNoneβnone,NONE,null,nilprintβprin,prnt,pritn
# Using Python directly
python3 phyton.py
# Using the launcher script
./phyton# Using Python directly (fuzzy matching disabled by default)
python3 phyton.py examples/quick_start.phy
# Using the launcher script (recommended)
./phyton examples/quick_start.phy
# Enable fuzzy matching for unknown misspellings
python3 phyton.py --fuzzy examples/quick_start.phy
./phyton --fuzzy examples/quick_start.phyPhyton accepts misspelled command line options too! Try these:
# These all work thanks to option misspelling correction:
./phyton --halp # β --help
./phyton --fuzy file.phy # β --fuzzy
./phyton --interactiv # β --interactivePhyton includes fuzzy matching that can correct unknown misspellings not in the predefined dictionary:
# Default behavior - fuzzy matching disabled
python3 phyton.py your_file.phy
# Enable fuzzy matching for unknown misspellings
python3 phyton.py --fuzzy your_file.phy
# Interactive mode (fuzzy disabled by default)
python3 phyton.py --interactiveExamples of fuzzy corrections:
defffβdefprinttβprintprrintβprint
β‘ Note: Fuzzy matching is disabled by default for predictable behavior. Use --fuzzy to enable advanced spelling correction.
All example files are located in the examples/ folder with memorable names:
quick_start.phy- Perfect first Phyton programhello_world.phy- Classic programming with misspellingsspelling_game.phy- Interactive spelling gameadvanced_features.phy- Complex programming constructsbad_spellers_paradise.phy- Maximum misspelling densityspelling_nightmare.phy- Ultimate stress test
See examples/README.md for detailed descriptions and learning path.
# This is valid Phyton code!
deff greet(name):
prin(f"Hello, {name}!")
iff name == "World":
greet("Phyton")
els:
greet("Python")klass Plant:
deff __init__(self, species):
self.species = species
deff grow(self):
retrun f"{self.species} is growing! πΏ"
fore i inn range(3):
plant = Plant(f"Plant {i}")
prin(plant.grow())For more examples, see the examples/ folder!
- Try the demo:
./demo.sh- Runs all 6 examples - Start simple:
./phyton examples/quick_start.phy - Go interactive:
./phytonfor REPL mode - Explore: Check
examples/README.mdfor learning path
Phyton includes a comprehensive test suite to ensure all functionality works correctly.
# Install test dependencies
pip install -r requirements.txt
# Run all tests with pytest
python -m pytest test_phyton.py -v
# Run tests with coverage
python -m pytest test_phyton.py --cov=phyton --cov-report=term
# Check code quality with pylint
pylint phyton.py
pylint test_phyton.pyThe test suite includes 130 tests covering:
- All keyword mappings (33 tests)
- Fuzzy matching functionality (15 tests)
- Command-line argument parsing (20 tests)
- File execution and error handling (25 tests)
- Interactive mode (10 tests)
- Edge cases and comprehensive coverage (27 tests)
Current coverage: 79% with perfect pylint score (10/10)
GitHub Actions automatically runs all tests on:
- Python 3.8, 3.9, 3.10, 3.11, and 3.12
- Code quality checks with pylint
- Coverage reporting
While Phyton can execute any .py file, we recommend using .phy extension for Phyton files to distinguish them from regular Python files.
Feel free to add more creative misspellings! The goal is to accept as many common typos and variations as possible while still being functional.
When contributing:
- Add tests for new functionality
- Ensure all tests pass:
python -m pytest test_phyton.py - Check code quality:
pylint phyton.py test_phyton.py - Update documentation as needed
Because everyone deserves to code, even if they can't spell "def" correctly! π±
