Combina c++ code and python code
You can use this project to combine c++ code and python code in one file.
How to use
1. Install
pip install combina_cpp_and_py
2. Use
Hypothesis that you have a cpp file named "test.cpp" and a python file named "test.py".
import combina_cpp_and_py
with open('test.cpp', 'r') as f:
cpp_code = f.read()
with open('test.py', 'r') as f:
py_code = f.read()
new_code = combina_cpp_and_py.combine(cpp_code, py_code)
with open('result.cpp', 'w') as f:
f.write(new_code)
with open('result.py', 'w') as f:
f.write(py_code)
3. Result
You will get a new cpp file named "result.cpp" and "result.py" which contains the combined c++ code and python code.
#if false
r"""
#endif
{$cppcode}
#if false
"""
{$pythoncode}
#endif
Explain
The code will be combined in the following way:
1. The c++ code will be placed in the {$cppcode} block.
2. The python code will be placed in the {$pythoncode} block.
3. When run c++, the {$pythoncode} block will be ignored due to "#if false" and "#endif".
4. When run python, the {$cppcode} block will be ignored due to "#" and " r"""""" ".
# 2025.5.8 v0.4.1
CHANGE
- use different way to deal with special code
2025.5.7 v0.3.1
FIX
- change the annotation in c++ code
2025.5.7 v0.3.0
ADD
-
add more special code
-
add more functions in combine.h
2025.5.6 v0.2.0
ADD
- add warning when special code in the code block
Metadata
Release files for combina-cpp-and-py 0.4.0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| combina_cpp_and_py-0.4.0.1.tar.gz | 9.7 kB | Without provenance | Details for combina_cpp_and_py-0.4.0.1.tar.gz |
Built distributions (wheels)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| combina_cpp_and_py-0.4.0.1-py3-none-win_amd64.whl | Python 3 | none | Windows x86-64 | Details for combina_cpp_and_py-0.4.0.1-py3-none-win_amd64.whl |
| combina_cpp_and_py-0.4.0.1-py3-none-win32.whl | Python 3 | none | Windows x86-32 | Details for combina_cpp_and_py-0.4.0.1-py3-none-win32.whl |
Total release size: 37.3 kB
Release files / combina_cpp_and_py-0.4.0.1.tar.gz
| Download URL | combina_cpp_and_py-0.4.0.1.tar.gz |
|---|---|
| Size | 9.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
e7fb62d3dd3d353fb4f42e075b8fea16b5a2e47438ba3631ee0b82c8a3edf37c
|
|
BLAKE2b-256 checksum How to use checksums |
1d361c7e6c950706eae0e04ce4fe35bf2b5a2a496a23ddd891d5a2995a93e7d3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.3
|
Release files / combina_cpp_and_py-0.4.0.1-py3-none-win_amd64.whl
| Download URL | combina_cpp_and_py-0.4.0.1-py3-none-win_amd64.whl |
|---|---|
| Size | 13.8 kB |
| Tags | Python 3 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
7e61f81b7793047a12573089de7d5b0ae821a5a092ceba2a46b25ac8306cc7e6
|
|
BLAKE2b-256 checksum How to use checksums |
47f3f30fbb23f533110c8b0ec330a1fa0eaba134eb8ffd3be6232d40baf84ca3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.3
|
Release files / combina_cpp_and_py-0.4.0.1-py3-none-win32.whl
| Download URL | combina_cpp_and_py-0.4.0.1-py3-none-win32.whl |
|---|---|
| Size | 13.8 kB |
| Tags | Python 3 Windows x86-32 |
|
SHA-256 checksum How to use checksums |
3d9d8a6feed5549e04a0fe51cb46b3be733449ed85fae685d1b000874e30aa0e
|
|
BLAKE2b-256 checksum How to use checksums |
aa14028f24d14e64640c6501c5f3b1ceb91cc7d4787c0c27474740becbbb1564
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.3
|
Security for combina-cpp-and-py 0.4.0.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.