[C++-sig] When You Create an Python Object Using Boost.Python, How Do You Find Out Its Name?

Nat Goodspeed ngoodspeed at solidworks.com
Mon Jul 9 22:36:52 CEST 2007


________________________________________
From: c++-sig-bounces at python.org [mailto:c++-sig-bounces at python.org] On Behalf Of Lawrence Spector
Sent: Monday, July 09, 2007 3:05 PM
To: c++-sig at python.org
Subject: [C++-sig] When You Create an Python Object Using Boost.Python, How Do You Find Out Its Name?

When I do something like this:

boost::python::object pyClass(MyInstance);

What name does it give it?  It doesn't appear it to give it pyClass as the name, but it has to pick something to identify itself for the Python-C API.  So, what's the name and how do I find out what it is?

[Nat] Should it have a name? If I write in a Python script:

class MyInstance(object):
    pass

foo = MyInstance()

the object instantiated by the MyInstance() call does not have an embedded name. The script's locals dict acquires an entry mapping "foo" to that new instance, but the name "foo" belongs to the dict rather than to the object.

Maybe I don't understand your question.



More information about the Cplusplus-sig mailing list