Function that knows the names of its actual parameters
Stefan Franke
spamfranke at bigfoot.de
Sun Jun 18 17:22:36 EDT 2000
On Fri, 16 Jun 2000 13:20:59 -0700, "John W. Baxter" <jwbnews at scandaroon.com> wrote:
>I would think that this method should point the way (you can have some
>positional arguments as well, along with named keyword ones, plus the
>catchall):
>
>>>> def m(**args):
>... print args
>...
>>>> m(a=5, b='ten')
>{'b': 'ten', 'a': 5}
>
Huh? Are we talking about the same thing? Keyword arguments either overwrite
existing ones or supply new ones along with the call. What I am looking for is
more or less (and arguably sensible) syntactic sugar for building a subdict
of locals() given non-quoted variable names:
magic(a, b, ...) <-> {"a": locals("a"), "b": locals("b"), ...}
This is obviously not meaningful for expressions as arguments. I don't making
this look like a function call is a good thing, but I do think the functionality is
quite useful sometimes (Python, HTML, SQL, etc. generation...).
even-though-I-don't-know-Perl-very-much-I'm-sure-it-has-a-special-syntax-for-that-kind-of-thing-ly y'rs
Stefan
More information about the Python-list
mailing list