Write python language in chinese
Project description
zhpy is the python on Chinese, which is good for Taiwan and China beginners to learn python in our native language.
zhpy is a lightweight python module and a source convertor, which provides a command line tool to translate python code. The python code written by traditional and simplified chinese could be translated to nature python code (english).
zhpy support full python syntax. Code written in zhpy could be converted to natual python and be used in normal python programs.
After v0.5, zhpy provide a method ‘zh_exec’ that allow to embed chinese script in python
After v0.6, zhpy could be used as the chinese script in shell as well.
zhpy is fully tested, which use ~50 test cases to test the small(<10k) source.
zhpy use pyparsing module to detect chinese keywords, class name, methods, arguments, variables and translate them back to python.
It’s possible for developers to port zhpy to python on korean or python on japenese.
Check examples here.
Install zhpy
You could use easy_install command to install zhpy:
$ easy_install zhpy
or check instructions for detail.
Usage
You could use interpretor to test zhpy with zh_exec method:
$ python >>> from zhpy import zh_exec >>> zh_exec("print hello") # execute zhpy here, pypi not allow non ascii code. hello
You could use ‘zhpy’ command instead of “python” in command line to execute source code mixed in Chinese and English.:
$ zhpy hello.py hello, world!
You could assign a file name to export the zhpy source to the normal python source (english):
$ zhpy hello.py n_hello.py
Then run the exported file as normal python source:
$ python n_hello.py hello, world!
Or you could combine these two steps in one command (with ‘-p’ option):
$ python -p hello.py hello, world! $ ls hello.py n_hello.py
check the BasicUsage for detail.
Programming
You could mix original english keywords and Chinese keywords in your zhpy source.
Reserved keywords are listed here
You could view the ChangeLog to see what’s new in these version
Project details
Release history Release notifications | RSS feed
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
File details
Details for the file zhpy-0.7.zip
.
File metadata
- Download URL: zhpy-0.7.zip
- Upload date:
- Size: 30.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 79d0e5173e48fd7898ea0641c000ade31089a4f8b5e586d7d38e008ff2f947f0 |
|
MD5 | 54ee839143642bd052b40d53865d61b2 |
|
BLAKE2b-256 | 1f8b69c3a680e8682c9b070c1ba671754bf1aec078411aa8950c56f9e86bc1ef |
File details
Details for the file zhpy-0.7-py2.5.egg
.
File metadata
- Download URL: zhpy-0.7-py2.5.egg
- Upload date:
- Size: 30.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 800ac34ef0c33406acf1254f8a6b0fa36b61ec3c4d70f2f68af241e23d08e19f |
|
MD5 | 43f5ad3203437266a64eb819f4854f14 |
|
BLAKE2b-256 | e0103a706d37e802e7aa55a5de05e28663bbb17baeb5b69d329ff2c2a006a831 |