[BangPypers] Calling Python script from C++.

Zubin Mithra zubin.mithra at gmail.com
Thu Feb 25 14:28:31 CET 2010


#!/usr/bin/python
# test.py
import sys
print sys.argv


$ python test.py myArgument

i hope this is what you required.



On 2/25/10, lakshmi.chowdam at bt.com <lakshmi.chowdam at bt.com> wrote:
> Hi Zubin,
>
> Deployment OS is RedHat Linux.
>
> Here is the python file : Hello.py
>
> Def sayHello(name):
> 	Print "Hello" + name
>
> sayHello(arg)
>
> and
>
> In c++ file, I am catching all the lines from the python file in string
> buffer and calling the PyRun_SimpleString(stringbuffer).
> It is working fine without passing any argument. But I want to send the
> argument to this python file from c++ file.
>
> Could you tell me how can I pass arguments to python file?
>
>
> Thanks,
> Lakshmi.
>
> -----Original Message-----
> From: bangpypers-bounces+lakshmi.chowdam=bt.com at python.org
> [mailto:bangpypers-bounces+lakshmi.chowdam=bt.com at python.org] On Behalf Of
> Zubin Mithra
> Sent: Thursday, February 25, 2010 5:11 PM
> To: Bangalore Python Users Group - India
> Subject: Re: [BangPypers] Calling Python script from C++.
>
> could you give us a few more details? the deployment OS?
>
>
> cheers!!!
> Zubin
>
>
>
> On Thu, Feb 25, 2010 at 12:51 PM,  <lakshmi.chowdam at bt.com> wrote:
>> Hi,
>>
>>
>>
>> We have a requirement of Calling Python script from C++.
>>
>>
>>
>> So, For this we are trying to pass entire python script(Script has  both
>> method implementation and method calls are exist) as a string and
>> executing this string by using PyRun_SimpleString().
>>
>>
>>
>> Our concern is that if python has a method with no arguments we are able
>> to execute it successfully
>>
>>
>>
>> But If Method takes parameters or arguments ,then how do we can pass
>> values to that method and how can we execute it?
>>
>>
>>
>> Could you please provide the solution.
>>
>>
>>
>> Thanks and Regards,
>>
>> Lakshmi Narasaiah C,
>>
>>
>>
>> _______________________________________________
>> BangPypers mailing list
>> BangPypers at python.org
>> http://mail.python.org/mailman/listinfo/bangpypers
>>
> _______________________________________________
> BangPypers mailing list
> BangPypers at python.org
> http://mail.python.org/mailman/listinfo/bangpypers
> _______________________________________________
> BangPypers mailing list
> BangPypers at python.org
> http://mail.python.org/mailman/listinfo/bangpypers
>


-- 
cheers!!!
Zubin


More information about the BangPypers mailing list