Skip to content
Snippets Groups Projects
Commit 29025685 authored by Jonathan Youett's avatar Jonathan Youett
Browse files

Add brackets to print command to make compile with python 3

parent 17014968
No related branches found
No related tags found
No related merge requests found
......@@ -60,7 +60,7 @@ int main(int argc, char** argv)
std::cout << std::endl;
std::cout << "Example 1: Execute a single line of python code *******************************" << std::endl;
{
pyMain.run("print 'Hello world!'");
pyMain.run("print('Hello world!')");
}
......@@ -75,7 +75,7 @@ int main(int argc, char** argv)
<< std::endl << " def __init__(self, s):"
<< std::endl << " self.s=s"
<< std::endl << " def f(self):"
<< std::endl << " print self.s"
<< std::endl << " print(self.s)"
<< std::endl << ""
<< std::endl << "a=A('Hello world!')"
<< std::endl << "a.f()";
......@@ -202,7 +202,7 @@ int main(int argc, char** argv)
<< std::endl << "try:"
<< std::endl << " import mymodule"
<< std::endl << "except:"
<< std::endl << " print 'mymodule was not found!'"
<< std::endl << " print('mymodule was not found!')"
<< std::endl;
// Create a new module not contained in a file
......@@ -219,11 +219,11 @@ int main(int argc, char** argv)
// Now we can import the new module into other module, e.g., main
// using its name.
pyMain.import("mymodule");
pyMain.run("print mymodule.f(mymodule.a, mymodule.b)");
pyMain.run("print(mymodule.f(mymodule.a, mymodule.b))");
// You can also import a Module by giving another name.
pyMain.importAs(myModule, "mymodule2");
pyMain.run("print mymodule2.f(mymodule.a, mymodule.b)");
pyMain.run("print(mymodule2.f(mymodule.a, mymodule.b))");
}
......@@ -275,7 +275,7 @@ int main(int argc, char** argv)
pyMain.set("result", Python::evaluate("2+3"));
// Now the name 'result' in __main__ holds a reference to the new result object.
pyMain.run("print result");
pyMain.run("print(result)");
}
......@@ -461,7 +461,7 @@ int main(int argc, char** argv)
pyMain.set("v", v);
// Let python print the content of the list.
pyMain.run("print v");
pyMain.run("print(v)");
}
......@@ -515,7 +515,7 @@ int main(int argc, char** argv)
// You can now also call the function in python directly...
std::cout << "Result of evaluating the created function g in python directly: ";
pyMain.run("print g(2)");
pyMain.run("print(g(2))");
// ... or by calling it manually.
std::cout << "Result of evaluating the created function g in python manually through the C++ interface: ";
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment