Manlio Perillo wrote:
Anyway, here is an example of what I would like to do:
#begin
def foo(**kwargs): print kwargs
foo(a = 1, b = 2, c = 3)
#end
In the current implementation kwargs is a dict, but I need to have the
keyword argument sorted.
Unfortunately subclassing fron dict and installing the class in the
__builtin__ module (with the name 'dict') does not work, CPython uses
only builtin types.
With the compiler module I can obtain the keyword arguments in the
order the were specified.
The problem is how to do this for every call to foo!
Why not just pass the kind of argument you want? What is it you really need
to do?
def foo(kwds): print kwds
foo(MyDict(a = 1, b = 2, c = 3))
Kent
--
http://mail.python.org/mailman/listinfo/python-list