I'm at a point with this program that I need to do a lot of work with strings. This would be so much simpler to do in Python, however I don't want the entire program written in Python. How could I use functions from a Python script in C++?

6 Years
Discussion Span
Last Post by WildBamaBoy

If you are doing a lot of work with strings (I assume parsing), here are some general options to consider (from simplest to most powerful):

- stringstream (basic string operations, like an I/O stream)
- Boost.Regex (Regular expressions)
- Boost.Tokenizer (splitting strings into tokens and manipulating them)
- Boost.Spirit (LL Parser in EBNF grammars)
- Boost.Xpressive (recursive context-free grammars and expression templates)

If you have a more specific task (like parsing XML), then it is very likely that specific libraries exist in C++ that can do what you want.

Other than that, I don't really know how to use Python in C++ (I'm guessing you can just launch Python scripts, but that's very basic and not very nice).


I've stopped this project for now but I'll have a look at the Boost.Tokenizer whenever I start back. Thank you.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.