On 25 Feb, 12:42, Doug Morse <[EMAIL PROTECTED]> wrote: > Hi, > > My apologies for troubling for what is probably an easy question... it's just > that can't seem to find an answer to this anywhere (Googling, pydocs, etc.)... > > I have a class method, MyClass.foo(), that takes keyword arguments. For > example, I can say: > > x = MyClass() > x.foo(trials=32) > > Works just fine. > > What I need to be able to do is call foo() with a string value specifying the > keyword (or both the keyword and value would be fine), something along the > lines of: > > x = MyClass() > y = 'trials=32' > x.foo(y) # doesn't work > > or > > x.MyClass() > y = 'trials' > x.foo(y = 32) # does the "wrong" thing >
Try this: y='trials' x.foo( **{y:32} ) Ciao ----- FB -- http://mail.python.org/mailman/listinfo/python-list