Skip to main content

Combina C++ and Python code

Project description

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.7 v0.3.0

ADD

  • add more special code

2025.5.6 v0.2.0

ADD

  • add warning when special code in the code block

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

combina_cpp_and_py-0.3.0.tar.gz (3.1 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

combina_cpp_and_py-0.3.0-py3-none-win_amd64.whl (8.0 kB view details)

Uploaded Python 3Windows x86-64

combina_cpp_and_py-0.3.0-py3-none-win32.whl (8.0 kB view details)

Uploaded Python 3Windows x86

combina_cpp_and_py-0.3.0-py3-none-any.whl (4.5 kB view details)

Uploaded Python 3

File details

Details for the file combina_cpp_and_py-0.3.0.tar.gz.

File metadata

  • Download URL: combina_cpp_and_py-0.3.0.tar.gz
  • Upload date:
  • Size: 3.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.3

File hashes

Hashes for combina_cpp_and_py-0.3.0.tar.gz
Algorithm Hash digest
SHA256 1d6e9b119225bf75c1db2c627b1f12b7e2a9620f51b2292ffca3c10d65d9d0a3
MD5 b3f7fdcdc1d893e68655b47169d05b52
BLAKE2b-256 23a9a3a3e020607e9c6b602262d393ad3ad2643171fa8b9939ce02316545cebc

See more details on using hashes here.

File details

Details for the file combina_cpp_and_py-0.3.0-py3-none-win_amd64.whl.

File metadata

File hashes

Hashes for combina_cpp_and_py-0.3.0-py3-none-win_amd64.whl
Algorithm Hash digest
SHA256 16be4c00d6eb41f1c9531667d8f068c27670caa3ccb985f33dce0f29318f81be
MD5 d33209d080576cb974dda80135b8f174
BLAKE2b-256 9bfde4c6a5db66ee54b58f076d6a4b4805bef531ab8b55138aea7ae2e54b9c23

See more details on using hashes here.

File details

Details for the file combina_cpp_and_py-0.3.0-py3-none-win32.whl.

File metadata

File hashes

Hashes for combina_cpp_and_py-0.3.0-py3-none-win32.whl
Algorithm Hash digest
SHA256 3edb2ad82a4cf98216972bcb6714ae4cf70300e4c8a1bacd29bc0dc4434bb7dd
MD5 45a83e95289415f5d19cacb50799ff73
BLAKE2b-256 ef9e357b976fbd0fb08b2b6c71f541c07763e4bc0ee24010d037ef0301726de3

See more details on using hashes here.

File details

Details for the file combina_cpp_and_py-0.3.0-py3-none-any.whl.

File metadata

File hashes

Hashes for combina_cpp_and_py-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 3889cab743cea9ec9f8a1b2fec7394199367960d995bb8ed403f33544db2d74f
MD5 35531a3f53d16f38e457ec70229c96c2
BLAKE2b-256 eb079b84ccf04e9926e25f001c8c0f876ec230aada4c1c80a4ff359a3d3425c7

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page