[Bf-python] PyRun_File vs PyRun_String

Campbell Barton ideasman42 at gmail.com
Sun May 11 14:14:18 CEST 2008


>From looking about on the net a lot of other people have this problem,
this seems the most common solution.

PyRun_SimpleString("execfile('foo.py')")

- In blender all the string parsing can be avoided with this..

		char pystring[sizeof(script->scriptname) + 14];
		pystring[0] = '\0';
		sprintf(pystring, "execfile('%s')", script->scriptname);
		py_res = PyRun_String( pystring, Py_file_input, py_dict, py_dict );

On Sat, May 10, 2008 at 6:37 PM, Campbell Barton <ideasman42 at gmail.com> wrote:
> wouldnt the python function do the necessary parsing? - if not then
> that wouldn't help, your right,
>
> On Sat, May 10, 2008 at 6:35 PM, Martin Poirier <theeth at yahoo.com> wrote:
>>
>> --- On Sat, 5/10/08, Campbell Barton <ideasman42 at gmail.com> wrote:
>>
>>> From: Campbell Barton <ideasman42 at gmail.com>
>>> Subject: Re: [Bf-python] PyRun_File vs PyRun_String
>>> To: "Blender Foundation Python list" <bf-python at blender.org>
>>> Date: Saturday, May 10, 2008, 12:32 PM
>>> Thanks, Ill mail the py/c api ml to see if there is a
>>> workaround.
>>> Maybe there could be a function that just accepts a
>>> filename?
>>
>> That wouldn't work either, we need to be able to run modified files (files that can contain cr/lf) from a buffer.
>>
>> Martin
>>
>>
>>      ____________________________________________________________________________________
>> Be a better friend, newshound, and
>> know-it-all with Yahoo! Mobile.  Try it now.  http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ
>> _______________________________________________
>> Bf-python mailing list
>> Bf-python at blender.org
>> http://lists.blender.org/mailman/listinfo/bf-python
>>
>



More information about the Bf-python mailing list