Today I learned that you can use emojis as variable names in Python if you use pythonji.

Snippet of Python code written with emojis.

Can you use emojis in Python?

No! At the time of writing, emojis are not valid Python identifiers. This means that this code fails:

>>> πŸ” = "hamburguer"   # SyntaxError

However, if you install the package pythonji , you will be able to run code like that!

Installing pythonji is as easy as python -m pip install pythonji!

With pythonji installed, we can run programs that make use of emojis!

Here's a little program I wrote:

import enum

class 🍽(enum.Enum):
    πŸ” = "hamburguer"
    πŸ• = "pizza"
    πŸ… = "tomato"
    πŸ₯• = "carrot"

class 🧍:
    def __init__(🀳, πŸ˜‹πŸ‘):
        🀳.πŸ˜‹πŸ‘ = πŸ˜‹πŸ‘

    def 🍽(🀳, πŸ˜‹):
        if πŸ˜‹ in 🀳.πŸ˜‹πŸ‘:
            return "Yummi!"
        else:
            return "Ok, I'll eat that."

πŸ‘¨ = 🧍([🍽.πŸ•, 🍽.πŸ₯•])
print(πŸ‘¨.🍽(🍽.πŸ•))
print(πŸ‘¨.🍽(🍽.πŸ…))

Save it to the file foo.🐍 (yes, the extension really is 🐍!).

Now, run it with pythonji foo.🐍 and this is the output:

 > pythonji foo.🐍
Yummi!
Ok, I'll eat that.

Amazing, right? πŸ˜†

That's it for now! Stay tuned and I'll see you around!

Become a better Python 🐍 developer πŸš€

+35 chapters. +400 pages. Hundreds of examples. Over 30,000 readers!

My book β€œPydon'ts” teaches you how to write elegant, expressive, and Pythonic code, to help you become a better developer. Get it below!

Download from

Previous Post Next Post

Blog Comments powered by Disqus.