[C++-sig] Any Boost.Python equivalent to **keywords?

Matt Giger mgiger at lunarsoft.com
Thu Mar 6 18:09:29 CET 2003


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...

Many thanks.
-- 
Matt Giger
Lunar Software, Inc.
mgiger at lunarsoft.com




More information about the Cplusplus-sig mailing list