ASPN ActiveState Programmer Network
ActiveState
/ Home / Perl / PHP / Python / Tcl / XSLT /
/ Safari / My ASPN /
Cookbooks | Documentation | Mailing Lists | Modules | News Feeds | Products | User Groups


Recent Messages
List Archives
About the List
List Leaders
Subscription Options

View Subscriptions
Help

View by Topic
ActiveState
.NET Framework
Open Source
Perl
PHP
Python
Tcl
Web Services
XML & XSLT

View by Category
Database
General
SOAP
System Administration
Tools
User Interfaces
Web Programming
XML Programming


MyASPN >> Mail Archive >> cpp-sig
cpp-sig
[C++-sig] wrapping global variables
by Dominique Devriese other posts by this author
Oct 20 2002 8:34PM messages near this date
Re: [C++-sig] splitting it into multiple pieces | Re: [C++-sig] wrapping global variables
Hi,
( please cc me as i'm not subscribed to the list)
I'm playing around a bit with embedding python in a C++ program.  I'm
using Boost.python for exposing the program's API to python, and the
normal python interface ( Py_Initialize, PyRun_SimpleString and
Py_Finalize ) for embedding.

So far this has proven surprisingly easy.  Especially Boost.Python has
amazed me with its ease of use, so congratulations to everyone here
who helped write it, as it most definitely rocks :)

But I have a question:  I would like to expose some global variables
to python.  E.g. if I have a variable curbuf, I would like to be able
to write ( in the embedded python interpreter, that is ) something
like "len = curbuf.length();".  curbuf is of class Buffer, and this
class has been exported very easily, but I don't seem to be able to
find how to expose a global variable.  Of course I can think of some
workarounds like exposing a free function, exposing a curbuf class
that has a singleton constructor, combining either of the above with
something like "PyRun_SimpleString( \"global a = freeFunOrClass();\"
);" ( If that is wrong python, that's because I'm more of a C++
programmer than a python programmer ;) etc., but I was wondering if
there wasn't a clean way to go about it.

I've browsed the c++-sig@[...].org archives a bit ( but as there
doesn't seem to be a search function, I've only read the last five
months or so ), and all i've found was this thread:
http://mail.python.org/pipermail/c++-sig/2002-July/001768.html
but it's not very clear...

So, is there a way to do this, or are there any plans to implement it
any time soon or are there any easy alternatives I'm missing ?
Thanks in advance
domi

-- 
Dominique Devriese

_______________________________________________
C++-sig mailing list
C++-sig@[...].org
http://mail.python.org/mailman/listinfo/c++-sig
Thread:
Dominique Devriese
David Abrahams
Dominique Devriese
David Abrahams
Dominique Devriese

Privacy Policy | Email Opt-out | Feedback | Syndication
© ActiveState Software Inc. All rights reserved