Re: [C++-sig] [JOB] C/C++/Linux Developers, NYC - Relo OK

2009-04-03 Thread Neal Becker
Beau Gould (OSS) wrote:

> I'm recruiting C/C++/Linux Developers for a NYC client.  Successful
> candidates:
...
> * do NOT have financial industry experience

Wow, I've never seen _that_ before!  What does it suggest??  Are those with 
financial experience tainted?


___
Cplusplus-sig mailing list
Cplusplus-sig@python.org
http://mail.python.org/mailman/listinfo/cplusplus-sig


Re: [C++-sig] instantiate python classes in c++

2009-04-03 Thread Gennadiy Rozental
Gregor Burger  uibk.ac.at> writes:

> is it possible to use boost.python to define classes
> in a script (like in the one below), register the defined
> classes and later on create instances of the class?

Yes
 
> Is it possible to provide the same globals and locals to call_method
> so that Flow and other classes are defined?

No. You can't "update" global dictionary at the call point. 

This is the issue I am very much familiar with. You can find 2 posts from me
with pretty much the same content.

The only viable solution I found is to *compile* the script first before
executing it. If I do this global dictionary is bound to the class methods and
you code will work fine.

Gennadiy

___
Cplusplus-sig mailing list
Cplusplus-sig@python.org
http://mail.python.org/mailman/listinfo/cplusplus-sig


[C++-sig] quickstart ?

2009-04-03 Thread mad city
I have just installed boost 1.38. I got the quickstart example to build.

1 - Why does bjam erase the extended.pyd file after running the tests?
2 - What options do I need, or changes to jamroot to prevent bjam from
erasing this file?
___
Cplusplus-sig mailing list
Cplusplus-sig@python.org
http://mail.python.org/mailman/listinfo/cplusplus-sig

[C++-sig] embedded python ?

2009-04-03 Thread mad city
Just starting out with boost-python. I have a python script that I want to
call from C++ code. I have the quickstart example working. I'm running into
a problem. The python script I'm calling includes import statements - for
example 'import os', and these are causing an exception

ImportError: __import__ not found

How do I resolve?
___
Cplusplus-sig mailing list
Cplusplus-sig@python.org
http://mail.python.org/mailman/listinfo/cplusplus-sig

Re: [C++-sig] embedded python ?

2009-04-03 Thread Stefan Seefeld

mad city wrote:
Just starting out with boost-python. I have a python script that I 
want to call from C++ code. I have the quickstart example working. I'm 
running into a problem. The python script I'm calling includes import 
statements - for example 'import os', and these are causing an exception


ImportError: __import__ not found  


Not having seen your code, I'd suggest you start by looking at the 
existing tests that use the functionality you want. In this case, this 
means the 'import' and 'exec' tests in boost/libs/python/test.


It's generally most likely to get help if you provide some details, such 
as a chunk of code that we could run to reproduce the issue.


Regards,
  Stefan

--

 ...ich hab' noch einen Koffer in Berlin...

___
Cplusplus-sig mailing list
Cplusplus-sig@python.org
http://mail.python.org/mailman/listinfo/cplusplus-sig


Re: [C++-sig] embedded python ?

2009-04-03 Thread mad city
Thanks. Good advice.

>From the quickstart project, the embedded.cpp file function


void exec_file_test(std::string const &script)
{
std::cout << "running file " << script << "..." << std::endl;

// Run a python script in an empty environment.
python::dict global;
python::object result = python::exec_file(script.c_str(), global,
global);

// Extract an object the script stored in the global dictionary.
BOOST_TEST(python::extract(global["number"]) ==  42);

std::cout << "success!" << std::endl;
}

calls my python script file - parseLogs.py which starts with

import os.path
import stat
import csv
import re
import pickle
import operator
import time
import msvcrt
from optparse import OptionParser
import sys

The 'import' call throws the exception - ImportError: __import__ not found.
I'm looking into the PyInitialize() and how the interpreter gets loaded.

Thanks.



On Fri, Apr 3, 2009 at 1:55 PM, Stefan Seefeld  wrote:

> mad city wrote:
>
>> Just starting out with boost-python. I have a python script that I want to
>> call from C++ code. I have the quickstart example working. I'm running into
>> a problem. The python script I'm calling includes import statements - for
>> example 'import os', and these are causing an exception
>>
>> ImportError: __import__ not found
>>
>
> Not having seen your code, I'd suggest you start by looking at the existing
> tests that use the functionality you want. In this case, this means the
> 'import' and 'exec' tests in boost/libs/python/test.
>
> It's generally most likely to get help if you provide some details, such as
> a chunk of code that we could run to reproduce the issue.
>
> Regards,
>  Stefan
>
> --
>
> ...ich hab' noch einen Koffer in Berlin...
>
> ___
> Cplusplus-sig mailing list
> Cplusplus-sig@python.org
> http://mail.python.org/mailman/listinfo/cplusplus-sig
>
___
Cplusplus-sig mailing list
Cplusplus-sig@python.org
http://mail.python.org/mailman/listinfo/cplusplus-sig

Re: [C++-sig] embedded python ?

2009-04-03 Thread troy d. straszheim

mad city wrote:

Thanks. Good advice.

 From the quickstart project, the embedded.cpp file function


void exec_file_test(std::string const &script)
{
std::cout << "running file " << script << "..." << std::endl;
   
// Run a python script in an empty environment.

python::dict global;
python::object result = python::exec_file(script.c_str(), global, 
global);


// Extract an object the script stored in the global dictionary.
BOOST_TEST(python::extract(global["number"]) ==  42);
   
std::cout << "success!" << std::endl;

}

calls my python script file - parseLogs.py which starts with


try something like this.  When you exec the file you have to supply a 
globals dictionary that contains whatever globals you want to use (like 
import)


Py_Initialize();

bp::object main = bp::import("__main__");
bp::object py_ = main.attr("__dict__");
bp::exec_file("conf.py", py_, py_);
int = bp::extract(py_["some_int_is_here"];

-t
___
Cplusplus-sig mailing list
Cplusplus-sig@python.org
http://mail.python.org/mailman/listinfo/cplusplus-sig


Re: [C++-sig] embedded python ?

2009-04-03 Thread Stefan Seefeld

mad city wrote:

Thanks. Good advice.

From the quickstart project, the embedded.cpp file function


void exec_file_test(std::string const &script)
{
std::cout << "running file " << script << "..." << std::endl;
   
// Run a python script in an empty environment.

python::dict global;
python::object result = python::exec_file(script.c_str(), global, 
global);


I'm not sure who suggested this, but I don't think this works, if the 
script runs anything interesting, as the builtin stuff is missing. (See 
the other mail for how to do it right.)


Thanks,
  Stefan


--

 ...ich hab' noch einen Koffer in Berlin...

___
Cplusplus-sig mailing list
Cplusplus-sig@python.org
http://mail.python.org/mailman/listinfo/cplusplus-sig