Python-plus-plus
所属分类:后台框架
开发工具:Shell
文件大小:12KB
下载次数:0
上传日期:2019-03-08 07:52:09
上 传 者:
sh-1993
说明: 用于创建Python C++多语言程序的框架,这些程序在两种编程语言中都有效
(A framework for creating Python C++ polyglots, programs valid in both programming languages)
文件列表:
COPYING (498, 2019-03-08)
examples (0, 2019-03-08)
examples\fibonacci.ppp (205, 2019-03-08)
examples\fizz_buzz.ppp (340, 2019-03-08)
examples\objects.ppp (371, 2019-03-08)
examples\ppp.ppp (10, 2019-03-08)
examples\temp.ppp (1250, 2019-03-08)
examples\tree.ppp (1519, 2019-03-08)
guide.md (7103, 2019-03-08)
ppp.ppp (10421, 2019-03-08)
scratchpad.ppp (1003, 2019-03-08)
test.sh (1724, 2019-03-08)
# Python++
_A framework for cross language development_
## About
Python++ is a framework for creating Python/C++ [polyglots](https://en.wikipedia.org/wiki/Polyglot_(computing)), programs valid in both programming languages. Specifically, it is a collection of guidelines and boilerplate that allows you to write a single program which will produce the same output when compiled with a C++14 compiler or run with a Python3 interpreter. It does this with heavy usage of C style macros and numerous hacks of the syntax of both languages. No external transpiler or preprocessor (aside from the standard C/C++ preprocessor) is needed. The exact same Python++ file can be fed in unmodified to a stock C++ compiler and a stock Python interpreter and you will get the same output. The first version of Python++ was developed by William W Wold for the Stupid Shit No One Needs and Terrible Ideas Hackathon 2017.
## Overview
Python++ consists of 3 things:
1. [ppp.ppp](ppp.ppp): This is itself a polyglot that can be copied to the top of your Python++ source, or placed alongside it and imported.
2. [guide.md](guide.md): A comprehensive guide to writing Python++ programs.
4. [examples](examples): examples of programs written in Python++.
## Running
__With Python__
Running Python++ programs with Python3 is easy. Simply enter
```
python3 your_source_file.ppp
```
__With C++__
It is a bit trickier to compile as C++ because the compiler doesn't recognize `.ppp` as a valid file extension by default. Also, you need support for C++14. With a recent version of GCC, the following command works:
```
g++ -x c++ -std=c++14 your_source_file.ppp -o output_binary
```
`-std=c++14` seems to be default on my system, but better to make it explicit. If you want to use an IDE or a different compiler I'm sure you can figure it out. If you do, feel free to edit this readme with instructions and send in a pull request.
__Test Script__
[test.sh](test.sh) is a BASH script that automatically tests the given source code with both Python and C++. You must have Python3 and gcc installed to use it. It reports if the program worked with Python, if it worked with C++ and if the outputs from the two languages match, as well as displaying the output and any error messages.
## Contributing
If you want to add a feature or fix a bug/typo, please do so and send in a pull request.
## License
Python++ is licensed under the permissive Do What The Fuck You Want To Public License (WTFPL). See [COPYING](COPYING) for details.
近期下载者:
相关文件:
收藏者: