How to do *args, **kwargs properly
Lasse Vågsæther Karlsen
lasse at vkarlsen.no
Tue Oct 11 08:02:15 EDT 2005
Max M wrote:
> Lasse Vågsæther Karlsen wrote:
>
>> I must be missing something but what is the proper way to do a
>> function using such arguments ?
>
>
>> - ability to take an unspecified number of "positional arguments"
>
>
> You should probably pass a sequence to the method instead. You can do it
> the other way, but it's poor coding style in most cases.
So what you're saying is that instead of:
def fn(*values, **options):
I should use:
def fn(values, cmp=cmp):
in this specific case?
and then instead of:
fn(1, 2, 3, cmp=...)
this:
fn([1, 2, 3], cmp=...)
<snip>
I think I'll re-write to use a list instead.
--
Lasse Vågsæther Karlsen
http://usinglvkblog.blogspot.com/
mailto:lasse at vkarlsen.no
PGP KeyID: 0x2A42A1C2
More information about the Python-list
mailing list