Skip to main content

Runs a cpp program written as a triplequoted string inside python

Project description

cpptopy

This is a project that helps you run C++ programs inside your python program. You can write your c++ code as is, inside a triple quoted string and call the run function , it will run the c++ code and return the output.

In the backend , the module creates a cpp source code file(with the name win_cpptopy.cpp) with the code that you pass as argument and executes the source code through command promt USING G++ COMPILER(MAKE SURE IT IS DOWNLOADED AND ADDED TO PATH) and delets all the aditional files it creates after the execution of the code. MAKE SURE THERE ARE NO COMPILE ERRORS IN THE C++ CODE THAT YOU WRITE AND ALSO MAKE SURE THAT THE STRINGS INSIDE THE C++ CODE ARE PROPERLY QUOTED TO NOT MESS WITH THE PYTHON SYNTAX.

ALSO NOTE THAT YOU CANNOT INTERACT DIRECTLY WITH THE C++ CODE ONCE IT RUNS.. SO FINCTIONS LIKE cin WONT WORK. PLEASE TAKE YOUR INPUTS THROUGH PYTHON.

Import the run_cpp object from the cpptopy module and create an instance as A. Then Call A.help() methord as it returns Further documentaion off each methord and best practices.

INSTALLATION

1)Open Commmand promt

  1. Check if pip is installed and added to path(write [pip --version] without brackets and if you get no errors then it's fine , otherwise install pip and add it to PATH

  2. In the command prompt type :

pip install cpptopy

and press ENTER.

Usage

EXAMPLE:

from cpptopy import run_cpp

N = input("Enter number")

from cpptopy import run_cpp

A = run_cpp()

n = input("Enter a number")

a =''' #include

int main() { int x =''' + n + ''';

std::cout << "The number is" <<''' + n + ''';

} '''

ans = A.run(a)

print(ans)

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

cpptopy-0.0.1.tar.gz (11.2 kB view details)

Uploaded Source

Built Distribution

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

cpptopy-0.0.1-py3-none-any.whl (3.1 kB view details)

Uploaded Python 3

File details

Details for the file cpptopy-0.0.1.tar.gz.

File metadata

  • Download URL: cpptopy-0.0.1.tar.gz
  • Upload date:
  • Size: 11.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.62.3 importlib-metadata/4.11.0 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.10.2

File hashes

Hashes for cpptopy-0.0.1.tar.gz
Algorithm Hash digest
SHA256 7ec42dc303ef61941b15309737b6fcbe79d5a2003a0bfa7f97e73c7e587e5356
MD5 6c377aeba91b03c63068d63891d764ad
BLAKE2b-256 77e8718f376aa4928ecb8c62ec595c6a0c7b5798ad0c05ec204d6e7aae0a1592

See more details on using hashes here.

File details

Details for the file cpptopy-0.0.1-py3-none-any.whl.

File metadata

  • Download URL: cpptopy-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 3.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.62.3 importlib-metadata/4.11.0 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.10.2

File hashes

Hashes for cpptopy-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 f7346268ff2fa6259a64da76884675116fc47fa125981b61c6716fafacd121c2
MD5 98f8edfe40dd67add7eb800eaa75d033
BLAKE2b-256 c6bf35384a98b54d8106648407aefacd2e56abca13774b71265d713582836a28

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