Dj Gilcrease wrote:
> If I understand right, positional only arguments would not be optional
> in any way shape or form, thats what default arguments are for.
I have been expecting that by providing a default value to an argument
in the definition that you are making it optional, be it keyword or
positional. The PEP doesn't have an example of what this means:
def f(a, b, *, c): ...
Is 'c' a keyword only argument that must be specified? In that case I
don't consider the following confusing, there is a clear indication of
which arguments are positional and which ones are keyword only.
def f(a, b=2, *, c=3): ...
Given this definition, which isn't in the PEP but maybe it should be:
def f(x, *):
I would be perfectly happy if there was an exception for f(x=3), just as
there is for math.sin(x=3).
> Positional only args would be arguments that you cannot specify by
> keyword, so having a positional only arg that has a default value,
> thus making it optional just seems broken to me.
I think this is a case of differing viewpoints. When I see a definition
like this:
def f(a, b=3): ...
I think of 'b' being an optional argument, you seem to see it
differently. I don't use keywords when I specify the values of
positional arguments, so if I see this in documentation:
min(iterable[, key=func]) -> value
I don't call min(iterable=[3]) because it returns a TypeError. So when
I see something like this:
def f(x, y):
I've never gotten in the habit of even trying f(y=2, x=3), and I would
consider it confusing even if and when it works. Then again, perhaps
it's because I've never felt compelled to reorder the sequence of values
of positional parameters when I call a function.
Joel
_______________________________________________
Python-3000 mailing list
[email protected]
http://mail.python.org/mailman/listinfo/python-3000
Unsubscribe:
http://mail.python.org/mailman/options/python-3000/archive%40mail-archive.com