Git Product home page Git Product logo

pythonji's Introduction

๐Ÿ - Write Python with Emojis

Write Python code using emojis ๐Ÿ

Example of running ๐Ÿ

Inspiration

Marc Garcia gave a wonderful lightning talk at EuroSciPy 2018 in Trento, where he pointed out some obvious deficiencies in Python's handling of unicode. For instance, code like the following is not supported:

import pandas as ๐Ÿผ

Installation

๐Ÿ is available on PyPI. Install it with pip:

$ python -m pip install pythonji

Using ๐Ÿ

๐Ÿ installs as pythonji. ๐Ÿ code files have the suffix .๐Ÿ. You can run a ๐Ÿ code file as follows:

$ pythonji file.๐Ÿ

Example

Save the following code to the file ๐Ÿผ.๐Ÿ:

import pandas as ๐Ÿผ
from numpy import random as ๐Ÿ”€

# Define a dataframe and print it to the console
๐Ÿ“‹ = ๐Ÿผ.DataFrame(
    {
        "๐Ÿ˜€": ["๐Ÿผ", "๐Ÿ", "๐Ÿฆ"],
        "๐Ÿท๏ธ": ["Panda", "Python", "Lion"],
        "๐Ÿ’ฏ": ๐Ÿ”€.randint(2, 5, size=3),
    },
).set_index("๐Ÿ˜€")
print(๐Ÿ“‹)

# Do some arithmetic with the dataframe
๐Ÿ”ค = f" Pythonji {' '.join(๐Ÿ“‹.index)}"
๐Ÿ”ข = ๐Ÿ“‹.loc["๐Ÿ", "๐Ÿ’ฏ"] + ๐Ÿ“‹.loc["๐Ÿผ", "๐Ÿ’ฏ"]
print(๐Ÿ”ค * ๐Ÿ”ข)

You can run the code as follows:

$ pythonji ๐Ÿผ.๐Ÿ 
        ๐Ÿท  ๐Ÿ’ฏ
๐Ÿ˜€           
๐Ÿผ   Panda  2
๐Ÿ  Python  2
๐Ÿฆ    Lion  4
 Pythonji ๐Ÿผ ๐Ÿ ๐Ÿฆ Pythonji ๐Ÿผ ๐Ÿ ๐Ÿฆ Pythonji ๐Ÿผ ๐Ÿ ๐Ÿฆ Pythonji ๐Ÿผ ๐Ÿ ๐Ÿฆ

Limitations

  • ๐Ÿ currently only handles single script files. It can import any regular Python module, but unfortunately not ๐Ÿ modules.
  • Sadly, pip does not currently handle unicode command names. Ideally, we want the executable to be named ๐Ÿ instead of pythonji.
  • Black unfortunately can not handle ๐Ÿ code. Does anybody want to contribute to โฌ›, a formatter for ๐Ÿ?

pythonji's People

Contributors

gahjelle avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

pythonji's Issues

Unicode decode error

I tried to execute the example provided in this repository, but I got

UnicodeDecodeError: 'charmap' codec can't decode byte 0x90 in position 19: character maps to <undefined>

Versions:
Windows 10
Python 3.8.10
Pythonji 0.1.1

pythonji fails when imported variables are used inside of a method

import pandas as pd
def rocket():
    print(pd.__version__)
rocket()
โฏ pythonji example/test.๐Ÿ
Traceback (most recent call last):
  File "/Users/pavel/micromamba/envs/test/bin/pythonji", line 8, in <module>
    sys.exit(main())
             ^^^^^^
  File "/Users/pavel/projects/pythonji/pythonji/__main__.py", line 19, in main
    run(py_file)
  File "/Users/pavel/projects/pythonji/pythonji/__main__.py", line 25, in run
    execute(py_file, new_path)
  File "/Users/pavel/projects/pythonji/pythonji/__main__.py", line 61, in execute
    exec(stuff)
  File "example/test.๐Ÿ", line 4, in <module>
    rocket()
  File "example/test.๐Ÿ", line 3, in rocket
    print(pd.__version__)
          ^^
NameError: name 'pd' is not defined. Did you mean: 'id'?

If you debug this in VSCode, you can see that the local namespace gets reset when entering the method:

outside the method:
image

inside the method:
image

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.