Lasse Vågsæther Karlsen wrote:
> Max M wrote:
> 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=...)
Precis
George Sakkis wrote:
> "Lasse Vågsæther Karlsen" <[EMAIL PROTECTED]> wrote:
>>I think I'll re-write to use a list instead
>
>
> Actually in most cases you don't need to assume it's a list; any
> iterable is usually good enough. You can always turn it into a list (or
> a tuple or a set or..) in t
"Lasse Vågsæther Karlsen" <[EMAIL PROTECTED]> wrote:
> 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=...)
>
>
>
>
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 ca
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
Lasse Vågsæther Karlsen <[EMAIL PROTECTED]> wrote:
...
> fn(1, 2, 3)
> fn(1, 2, 3, cmp=lambda x, y: y-x)
> fn(1, 2, 3, cpm=lambda x, y: y-x) # TypeError on this
I assume these are your specs.
> or is the "proper python" way simply this:
>
> def fn(*values, **options):
> if "cmp" in optio
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
I must be missing something but what is the proper way to do a function
using such arguments ?
Specifically I'm looking for:
- ability to take an unspecified number of "positional arguments"
- ability to take optional named arguments that follows the first arguments
- raise appropriate errors if