Why does PyRun_SimpleFile need a char*, not a const char*?

Adam Langley usenet at imperialviolet.org
Mon Dec 2 15:39:18 EST 2002


On Mon, 02 Dec 2002 08:53:49 +0100, Gernot Hillier wrote:

> Hi!
> 
> As I'm using embedded python in C++, I would really like to use
> 
> string a="bla.py"
> script_f=fopen(a.c_str(),"r")
> PyRun_SimpleFile(script_f, a.c_str());
> 
> But this only gives me "invalid conversion from `const char*' to `char*'" in 
> PyRun_SimpleFile(). :-(
> 
> So - why does PyRun_SimpleFile() expect to get a "char*" and not a "const 
> char*"?

Generally, C programmers aren't used to using `const' much and don't put
it when they could. You could call it a bug, but I would just const_cast
the problem away.





More information about the Python-list mailing list