Embedding Question from a Newbie
Gordon McMillan
gmcm at hypernet.com
Sat Jun 12 00:23:53 EDT 1999
CyRiuS writes:
> i have a question. i am new to python and am trying to use it as a
> scripting language for a game i am working on. I have the
> interpreter embedded and running scripts but i have a few questions.
>
> 1) can i return values from the python script to the C/C++ program?
> for example say at the end of my script, it returned 'character' and
> character was equal to say 'hi' now is there anyway my C/C++ program
> could find out that the script just returned the value 'hi'?
>
> 2) is there anyway I can pass values from the C/C++ program into the
> python script?
>
> and
>
> 3) say i had a python script that had several functions (defs). is
> there anyway i could call just one of these defs from the C/C++
> program without calling the entire script?
The answer to all 3 is yes. The details will be found in the
embedding docs and the C API docs. I'd guess so far you've only used
the Very High Level layer (PyRun_ etc). You want to start exploring
the Abstract layer, where you work with PySequences and such. At that
level it's still pretty straight forward. Drop down further only if
you really have to. Almost anything you'll need to do is done
somewhere in the Modules or Objects subdirectories.
grep-is-your-best-friend-ly y'rs
- Gordon
More information about the Python-list
mailing list