Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

I want to use Python as a scripting language for my game, can I use it purely with C (not C++)? It is important to me that I not use C++, and purely use C instead.

share|improve this question
7  
Please do some cursory research before asking questions. –  user744 Aug 3 '11 at 5:48
    
I agree with @Joe Wreschnig but i dont agree on the downvote: 0 is worse than -1 (it attracts less attention) and there are chances that someone gives smart answers to dumb questions. –  FxIII Aug 3 '11 at 7:22
    
@FxIII a chance of getting a smart answer is not a reason to keep a bad question, otherwise you wouldn't close anything and it would be all a mess. –  Lohoris Aug 3 '11 at 7:31
1  
@Fxlll (Can't tell if your name is i or l) The idea of downvotes is to show that a question is either poorly worded, vague, off topic, or in this case, just not researched at all. –  The Communist Duck Aug 3 '11 at 8:14
3  
It's amazing how much people will spend energy telling someone they are wrong, have asked a dumb question, or that they haven't done any research. How simple it is to just answer the question instead, offer a little advice that takes you a minute to create, and move on. Let's make people feel welcome here, not that it's a bunch of moderator nazis flaunting their high scores. –  Tim Holt Aug 3 '11 at 15:50

2 Answers 2

up vote 4 down vote accepted

As the official Python website/documentation suggest, "yes" you can embed Python purely with C.

share|improve this answer

I know that is not strictly related to your question (for which the answer is simply yes) but you should consider to extend Python with your C function or to use another language for scripting, Lua perhaps.

You can try the first option by compiling your C functions as dynamic library and then use ctypes. This gives you the chance to have a working prototype in almost no time.

If you profiled your C app before, you can profile the protype too, comparing the two to evaluate the ctypes overhead; ctypes (Foreign Function Interface in general) is not embedding but you have chances to see that this is suitable for you with little or no modification

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.