On Sat, 16 Apr 2005 14:02:32 -0700, Brian Sabbey <[EMAIL PROTECTED]> wrote:
>Bengt Richter wrote: >> On Fri, 15 Apr 2005 19:32:02 -0700, James Stroud <[EMAIL PROTECTED]> wrote: >>>> Examples >>>> ======== >>>> >>>> Using suite-based keyword arguments, the code >>>> >>>> f(x = 1) >>>> >>>> is equivalent to >>>> >>>> f(): >>>> x = 1 >> >> f(**def(): >> x = 1 >> return vars()) > >Yes, it seems it would just be sugar for full lambdas. Although, in this >example and the others, wouldn't you have to actually call the anonymous >function? D'oh, yes, but you got the idea ;-) > >f(**(def(): > x = 1 > return vars())()) > >Otherwise it seems like you are trying to pass a function, not the >keywords the function returns. > >One could, of course, also do the same with a named function: > >def no_longer_anonymous(): > x = 1 > return vars() > >f(**no_longer_anonymous()) Yes, but that does away with the trailing suite definition of the bindings from the pov of f ;-) BTW, I hope you will read my latest post replying to Kay Schluehr, where I propose some different spellings ;-) f(): x = 1 would be spelled f(**kw) where: kw = dict(:: x = 1) or could also be f(x=x) where: x = 1 "::" is a unary suite operator that returns an ordered vars().items() representing the net bindings made in the suite (i.e. del <name> will remove a binding just as for vars()). ::<suite> is a first class expression. items = :: x = 1 y = 2 print items => (('x', 1), ('y', 2)) "where:" is an expression trailer introducing a suite like :: except that the bindings are used to evaluate the names in the expression that the "where:" trails, not to produce an items() tuple. See the other post replying to Kay for more, superseding some things in my reply to you ;-) Regards, Bengt Richter -- http://mail.python.org/mailman/listinfo/python-list