[Bf-python] PyRun_File vs PyRun_String

Willian Padovani Germano wpgermano at gmail.com
Mon May 12 18:33:18 CEST 2008


Hi,

Campbell Barton wrote:
> Loading text as a blender textblock seems overkill.
> Why not just use PyRun_File and ifdef WIN32 to use
> PyRun_String("execfile('.....")?

Reusing Blender's code (add_text()) seems good because we can 
standardize all places where loading a script file and cleaning it up is 
done: scripts executed from the Text Editor, menu scripts and, in the 
future, all possibilities of executing scripts from the file system: 
scriptlinks, spacehandlers, pynodes, etc.

It may be just a little overkill, but if it works well, imo it's a good 
solution. We can also change Blender code a little to allow the option 
of loading without adding the textblock (via parameter or using another 
function instead of add_text()), so we don't have to unlink it. Then it 
would do only what we need and we avoid special cases / hacks.

But what you suggest is another possibility worth testing, of course.

-- 
Willian



More information about the Bf-python mailing list