Support for emoji digits in Python
Project description
Emojit
This package aims to address a long-standing Python issue:
int("1️⃣") != 1
Usage
from emojit import emj
emoji_str = emj("4️⃣0️⃣2️⃣")
assert isinstance(emoji_str, str) is True
assert int(emoji_str) == 402
Please, don't actually use this.
Simplified usage
You can simplify the previous example as:
# coding: emoji-digit
emoji_str = "4️⃣0️⃣2️⃣"
assert isinstance(emoji_str, str) is True
assert int(emoji_str) == 402
To achieve this, you have to do two things. Find your site-packages directory:
python -c "import site; print(site.getsitepackages())"
And then create a new file called sitecustomize.py in this directory with the following contents:
import builtins
import codecs
import emojit
import emojit.emoji_digit_codec
builtins.emj = emojit.emj
codecs.register(emojit.emoji_digit_codec.search_function)
You can read more about codecs here.
Advanced usage
Underscores as visual separators
from emojit import emj
assert int(emj("4️⃣0️⃣2️⃣_0️⃣0️⃣0️⃣")) == 402_000
Shorthand emojis
from emojit import emj
assert int(emj("🔟")) == int(emj("1️⃣0️⃣"))
assert int(emj("💯")) == int(emj("1️⃣0️⃣0️⃣"))
assert int(emj("🔢")) == int(emj("1️⃣2️⃣3️⃣4️⃣"))
Support
This package is considered feature complete. It will be archived once the functionality is upstreamed into the Python standard library.
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file emojit-1.1.0.tar.gz.
File metadata
- Download URL: emojit-1.1.0.tar.gz
- Upload date:
- Size: 2.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.4 CPython/3.12.2 Darwin/24.6.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4c7584dbb3b43b136d29536f80725ebf5b5476a55b7eac679953f0579824f698
|
|
| MD5 |
67736136ad0f81aac35e08e5a7bedeb7
|
|
| BLAKE2b-256 |
fd8d9d09d507aa1c2d00fbf0de51fec3da82b6640ea5ca84a0337e66e6c1737d
|
File details
Details for the file emojit-1.1.0-py3-none-any.whl.
File metadata
- Download URL: emojit-1.1.0-py3-none-any.whl
- Upload date:
- Size: 3.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.4 CPython/3.12.2 Darwin/24.6.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
71d0d615f665636b1ca5b78ad0000cb26ec6fd52bd98aa8de48c508c4865177a
|
|
| MD5 |
ceb3b833ffdb0684a80ef5135ada1467
|
|
| BLAKE2b-256 |
ebb192033de4c0c0d67c8740ac684863b2733b5d8bb6469ec2e939e50024da46
|