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++?

Recommended Answers

All 3 Replies

what is it that you want to do with strings? There's possibly an equivalent in c++.

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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.