Re: Python newbie trying to embed in C++

2013-02-28 Thread Marwan Badawi

On 27/02/2013 10:26, Ian Kelly wrote:

On Wed, Feb 27, 2013 at 1:51 AM, Marwan lar...@free.fr wrote:

When I run the generated exe, I get errors about the functions not
existing...

TestPython.exe test Hello
AttributeError: 'module' object has no attribute 'Hello'
Cannot find function Hello


test is the name of a module in the standard library.  My guess
would be that for some reason it's importing that module rather than
your test.py.  Make sure that test.py can be found on your sys.path,
and perhaps change the name of your module to reduce confusion.

I just noticed that my reply went to the message sender and not to the 
newsgroup, so I'm posting again: thanks, that was it. Just renaming my 
test.py file solved the problem.


%M
--
http://mail.python.org/mailman/listinfo/python-list


Re: Python newbie trying to embed in C++

2013-02-28 Thread Marwan Badawi

On 27/02/2013 16:17, Christian Gollwitzer wrote:

Am 27.02.13 09:51, schrieb Marwan:

And I'd appreciate it if you could give me pointers to how to easily
call Python from C++.


Maybe you can use boost::python?

http://www.boost.org/doc/libs/1_53_0/libs/python/doc/

Cave: I haven't used it and don't know if it is up-to-date.

 Christian

I just noticed that my reply went to the message sender and not to the 
newsgroup, so I'm posting again: thanks, I'll look into that.


%M
--
http://mail.python.org/mailman/listinfo/python-list


Re: Python newbie trying to embed in C++

2013-02-28 Thread Gisle Vanem

Marwan Badawi marwan.bad...@inria.fr wrote:

I just noticed that my reply went to the message sender and not to the 
newsgroup, so I'm posting again: thanks, I'll look into that.


Yes, I often do that too; i.e. I'm subscribed to python-list@python.org
and get all messages from comp.lang.python mirrored to the ML a bit later.
I prefer the mailing-list over comp.lang.python since my NNTP server
(eternal-september.org) is rather slow and my ISP has deprecated NNTP 
long time ago. 


I saw you uses Thunderbird on Windows. I'm not sure how it by default handles
a reply-to when there is no Reply-to field in the header. To the address in 
From / Sender or what? 


I wish the NNTP-mailing list gateway could add a Reply-to: 
python-list@python.org.
Since I'm getting the messages via the ML, I think it would be logical that the replies 
should by default go to the ML too.


--gv



--
http://mail.python.org/mailman/listinfo/python-list


Re: Python newbie trying to embed in C++

2013-02-28 Thread Michael Torrie
On 02/28/2013 03:47 AM, Gisle Vanem wrote:
 I saw you uses Thunderbird on Windows. I'm not sure how it by default handles
 a reply-to when there is no Reply-to field in the header. To the address in 
 From / Sender or what? 

Thunderbird has a handy, reply to list button that works every time no
matter what the rely-to field is set to.

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python newbie trying to embed in C++

2013-02-27 Thread Ian Kelly
On Wed, Feb 27, 2013 at 1:51 AM, Marwan lar...@free.fr wrote:
 When I run the generated exe, I get errors about the functions not
 existing...

 TestPython.exe test Hello
 AttributeError: 'module' object has no attribute 'Hello'
 Cannot find function Hello

test is the name of a module in the standard library.  My guess
would be that for some reason it's importing that module rather than
your test.py.  Make sure that test.py can be found on your sys.path,
and perhaps change the name of your module to reduce confusion.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python newbie trying to embed in C++

2013-02-27 Thread Christian Gollwitzer

Am 27.02.13 09:51, schrieb Marwan:

And I'd appreciate it if you could give me pointers to how to easily
call Python from C++.


Maybe you can use boost::python?

http://www.boost.org/doc/libs/1_53_0/libs/python/doc/

Cave: I haven't used it and don't know if it is up-to-date.

Christian

--
http://mail.python.org/mailman/listinfo/python-list


Re: Python newbie trying to embed in C++

2013-02-27 Thread Terry Reedy

On 2/27/2013 3:51 AM, Marwan wrote:

Hello all,

I'm new to Python and just starting to learn it. For he needs of my
project, I need to call some specific methods in Python scripts from C++.

For now, I just compiled the example in the Python documentation about
Pure Embedding to try it out (
http://docs.python.org/2/extending/embedding.html#pure-embedding ).

I'm trying to test it on an extremely simple script called test.py which
contains the following:

def testPY( value ):
print('You input ', value )

  def Hello():
 print('Hello')


I hope that the second def is not really indented in your original ;-).


When I run the generated exe, I get errors about the functions not
existing...

TestPython.exe test Hello
AttributeError: 'module' object has no attribute 'Hello'
Cannot find function Hello

My Python version is 2.7.3 because that's the version used in the module


The windows 2.7 on python.org is compiled with VS2008.


we need to access. And I'm using VS2010 SP1 for compiling my C++ because
that's the version used to generate our DLLs and EXEs.


Mixing VS compilers can be a problem, though I don't know if that is the 
case here. Even if not, it might be for your real application.


You can try compiling 2.7.3 (or later from repository) with vs2010. I 
know people have tried it. I presume it has been done. I don't know if 
there is an (unofficial) vs2010 project file in the repository.


Python.org 3.3 *is* compiled with 2010. You can also try running the 
module with that, possibly with the help of 2to3. It might not take too 
work. The author of the module might be interested in a port anyway, 
though maybe not. Or maybe extract just the part of the module you need 
for conversion.


You might start with 3.3 for your tests and initial learning to make 
sure that compiler mismatch is not a factor. When you get that to work, 
then decide what to do.


I suppose the worst alternative might be to regenerate all the needed 
dlls and exes with 2008.


--
Terry Jan Reedy

--
http://mail.python.org/mailman/listinfo/python-list