[C++-sig] enum strangeness...

Alex Mohr amohr at pixar.com
Thu Nov 10 03:12:21 CET 2005


I noticed something today about enums that I've wrapped with 
boost.python.  Here's a small example.

#include <boost/python.hpp>
using namespace boost::python;

struct Foo {
	enum Bar { Baz };
};

BOOST_PYTHON_MODULE(Mod) {
	scope fooScope = class_<Foo>("Foo");
	enum_<Foo::Bar>("Bar")
		.value("Baz", Foo::Baz)
		.export_values();
}

Now, in Python I can refer to the enum values by saying 'Mod.Foo.Baz' 
which is what I expect, but it seems to recur in a strange way.  I can 
also say:

Mod.Foo.Baz.Baz.Baz.Baz.Baz.Baz.Baz.Baz

for as long as I like.  This seems relatively benign, but strange.  Is 
it expected?

Thanks,

Alex



More information about the Cplusplus-sig mailing list