Skip to main content

_ allows you to write Python code using only _.

Project description

_

_ allows you to write Python code using only _.

Installation

[!TIP] It is highly recommended to use a virtual environment for proper installation of the _.pth file.

python -m pip install underscores

Python 3.9 or a newer version is required.

Usage

The following script is a "Hello, world!" program which can be executed by the Python interpreter:

# coding: _
_ ____ _ _____ _ ____ __ _ _ ___ ______ ____ _ ____ _ ___ _ ____ __ ___ _ __ _
_____ _ _ ______ _____ _ ___ _ _ _ ___ _____ ______ _ ____ _ _ _ ____ _ _ _ ____
_ ____ _ __ __ ___ _ _ ______ ___ _ ____ __ ______ _ ____ _ ____ _ ____ __ _ _
____ _ _ _ ___ _____ _____ _ _ ______ ____ _ _ ______ _____ _ __ _ ______

You can generate a script with _:

print('print("Hello, world!")'.encode("_").decode("utf-8"))

A _ command is also provided:

_ script1.py > script2.py
# or
echo 'print("Hello, world!")' | _ > script.py

Troubleshooting

If you get SyntaxError: invalid syntax, make sure the line # coding: _ is present at the top of your script.

If you get SyntaxError: encoding problem: _, follow the steps below to make sure the _ encoding is registered on startup:

  1. Run SITE_PACKAGES=$(python -c 'import sysconfig; print(sysconfig.get_path("purelib"))') to get the path to the Python site-packages directory.
  2. Run echo "import underscores" > "$SITE_PACKAGES/_.pth" to register the _ encoding on startup.

[!NOTE] If using PowerShell, use $SITE_PACKAGES instead of SITE_PACKAGES to assign the variable.

This issue is commonly encountered when installing _ into the user site-packages.

Credits

_ is a port of _ from Ruby to Python. Please check out the original creator mame.

Big thanks to shailist for this awesome post about custom encodings.

License

MIT License

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

underscores-0.0.3.tar.gz (6.1 kB view details)

Uploaded Source

File details

Details for the file underscores-0.0.3.tar.gz.

File metadata

  • Download URL: underscores-0.0.3.tar.gz
  • Upload date:
  • Size: 6.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.0

File hashes

Hashes for underscores-0.0.3.tar.gz
Algorithm Hash digest
SHA256 c949b4ec076471a2bd4ee86a13465e55f49b041028b7d5d48a02cf3b98872127
MD5 b3b59dacb72778f385182d32d0d3fee8
BLAKE2b-256 506a0cbc5e4670c7e7fde6719174c80f6eef1fbf8c3eaaf0c7e29203fba49868

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