Lasse Vågsæther Karlsen <[EMAIL PROTECTED]> writes:
> or is the "proper python" way simply this:
>
> def fn(*values, **options):
> if "cmp" in options: comparison = options["cmp"]
> else: comparison = cmp
> # rest of function here
>
> and thus ignoring the wrong parameter names?
I don't know about "proper" but it's pretty common. You could also
use a positional arg:
def fn(cmp, *values):
# blah blah
fn(cmp, 1, 2, 3) # call the function
You could check for invalid keys a little more concisely than in your
example. For example with sets:
def fn(*values, **options):
if Set(options.keys()) - Set(('cmp')):
raise error...
--
http://mail.python.org/mailman/listinfo/python-list