[BangPypers] python with c bindings
well recently i learned about handling shell scripts inside c files . well i was wondering since python is also scripting language can i bind the python script inside a "C" file and then run it.well on the front it may look like normal compilation of c program, but in the backend i guess the python script is being executed. ___ BangPypers mailing list BangPypers@python.org http://mail.python.org/mailman/listinfo/bangpypers
Re: [BangPypers] python with c bindings
On Tue, Jun 15, 2010 at 12:45 PM, Rahul R wrote: > well recently i learned about handling shell scripts inside c files . well > i was wondering since python is also scripting language can i bind the > python script inside a "C" file and then run it.well on the front it may > look like normal compilation of c program, but in the backend i guess the > python script is being executed. > you can #include in your c program and then call the python modules in a python script as explained here http://www.linuxjournal.com/article/8497 -- regards --- Kunal Ghosh Dept of Computer Sc. & Engineering. Sir MVIT Bangalore,India Blog:kunalghosh.wordpress.com Website:www.kunalghosh.net46.net ___ BangPypers mailing list BangPypers@python.org http://mail.python.org/mailman/listinfo/bangpypers
Re: [BangPypers] python with c bindings
On Tue, Jun 15, 2010 at 11:24 AM, kunal ghosh wrote: > On Tue, Jun 15, 2010 at 12:45 PM, Rahul R wrote: > > > well recently i learned about handling shell scripts inside c files . > well > > i was wondering since python is also scripting language can i bind the > > python script inside a "C" file and then run it.well on the front it may > > look like normal compilation of c program, but in the backend i guess the > > python script is being executed. > > > > you can #include > in your c program and then call the python modules in a python script > as explained here http://www.linuxjournal.com/article/8497 > i rather prefer running it as a script binding into a "C" (if thats possible , well that certainly works for sh scripts i dont know whether that works for python ) ___ BangPypers mailing list BangPypers@python.org http://mail.python.org/mailman/listinfo/bangpypers
Re: [BangPypers] python with c bindings
2010/6/15 Rahul R : > On Tue, Jun 15, 2010 at 11:24 AM, kunal ghosh wrote: > >> On Tue, Jun 15, 2010 at 12:45 PM, Rahul R wrote: >> >> > well recently i learned about handling shell scripts inside c files . >> well >> > i was wondering since python is also scripting language can i bind the >> > python script inside a "C" file and then run it.well on the front it may >> > look like normal compilation of c program, but in the backend i guess the >> > python script is being executed. >> > >> >> you can #include >> in your c program and then call the python modules in a python script >> as explained here http://www.linuxjournal.com/article/8497 >> > > > i rather prefer running it as a script binding into a "C" (if thats possible > , well that certainly works for sh scripts i dont know whether that works > for python ) Make the python script executable and run it just like the shell script. You can make a python script executable by adding the following in the first line. #! /usr/bin/env python And you need to chmod it. $ chmod +x your-script.py Anand ___ BangPypers mailing list BangPypers@python.org http://mail.python.org/mailman/listinfo/bangpypers
Re: [BangPypers] python with c bindings
On Tue, Jun 15, 2010 at 9:11 PM, Rahul R wrote: [..] > i rather prefer running it as a script binding into a "C" (if thats possible > , well that certainly works for sh scripts i dont know whether that works > for python ) I'm not sure what you mean by "binding". But is possible to embed a Python interpreter into your compiled C application so that it can execute scripts. It's often used to provide "scriptability". Perhaps you can elaborate a little on how you'd do it in shell. I'm not exactly sure what you want to accomplish. -- ~noufal http://nibrahim.net.in ___ BangPypers mailing list BangPypers@python.org http://mail.python.org/mailman/listinfo/bangpypers
Re: [BangPypers] python with c bindings
On Tue, Jun 15, 2010 at 6:03 PM, Noufal Ibrahim wrote: > On Tue, Jun 15, 2010 at 9:11 PM, Rahul R wrote: > [..] > > i rather prefer running it as a script binding into a "C" (if thats > possible > > , well that certainly works for sh scripts i dont know whether that works > > for python ) > > I'm not sure what you mean by "binding". But is possible to embed a > Python interpreter into your compiled C application so that it can > execute scripts. It's often used to provide "scriptability". > > well thats wat exactly i wanted .. to embed the python interpreter into C app . Can u throw some light on it .. on how to go about doing so. I apologise for not being articulate since , i did know the right jargon to express it. ___ BangPypers mailing list BangPypers@python.org http://mail.python.org/mailman/listinfo/bangpypers
Re: [BangPypers] python with c bindings
On Tue, Jun 15, 2010 at 21:42, Rahul R wrote: > I apologise for not being articulate since , i did know the right jargon to > express it. Can you please say what you meant by "handling shell scripts inside c files"? -- http://roshan.mathews.in/ ___ BangPypers mailing list BangPypers@python.org http://mail.python.org/mailman/listinfo/bangpypers
Re: [BangPypers] python with c bindings
On Tue, Jun 15, 2010 at 9:42 PM, Rahul R wrote: > On Tue, Jun 15, 2010 at 6:03 PM, Noufal Ibrahim wrote: > >> On Tue, Jun 15, 2010 at 9:11 PM, Rahul R wrote: >> [..] >> > i rather prefer running it as a script binding into a "C" (if thats >> possible >> > , well that certainly works for sh scripts i dont know whether that works >> > for python ) >> >> I'm not sure what you mean by "binding". But is possible to embed a >> Python interpreter into your compiled C application so that it can >> execute scripts. It's often used to provide "scriptability". >> >> > well thats wat exactly i wanted .. to embed the python interpreter into C > app . > Can u throw some light on it .. on how to go about doing so. http://docs.python.org/release/2.5.2/ext/embedding.html Try that? -- ~noufal http://nibrahim.net.in ___ BangPypers mailing list BangPypers@python.org http://mail.python.org/mailman/listinfo/bangpypers