Matt Giger <mgiger@lunarsoft.com> writes:
I would like to construct a class with a **keywords construct:
class tclass: def __init__(self, **keywords) for k in kw.keys() self.__dict__[k] = kw[k]
t = tclass(a = 1, b = 2, c = 3) t.a, t.b, t.c 1, 2, 3
I realize that this sort of open-ended Python construct would probably be difficult to generate with templates. I've looked through the test cases in the 1_29_0 distribution and can't find anything to do this.
It probably wouldn't be too hard to generate a helper function to turn a **keywords construct into a dictionary and use that to initialize a C++ defined class object, I was just wondering if there was a built in way...
I have some changes sitting on my disk that will allow you to do this; I'll try to check it in later today. -Dave -- Dave Abrahams Boost Consulting www.boost-consulting.com