[Bf-python] PyRun_File vs PyRun_String

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


It doesn't need to, the function already deals with that case
elsewhere. Im just interested in making menu items run without having
to parse the file.

On Sun, May 11, 2008 at 2:31 PM, Martin Poirier <theeth at yahoo.com> wrote:
>
> --- On Sun, 5/11/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: Sunday, May 11, 2008, 8:14 AM
>> >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 );
>
>
> How does that run a file with cr/lf that was loaded in the text editor and modified (but not saved)?
>
> 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