[Python-3000] PEP 3102

Georg Brandl g.brandl at gmx.net
Fri Feb 15 21:25:33 CET 2008


Dj Gilcrease schrieb:
> On Fri, Feb 15, 2008 at 8:46 AM, Joel Bender <jjb5 at cornell.edu> wrote:
>>  How about a BNFish notation?  Use brackets around optional parameters.
>>
>>      def test([arg1, [arg2,]] arg3):
>>          ...
> 
> If I understand right, positional only arguments would not be optional
> in any way shape or form, thats what default arguments are for.
> 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.

Being positional-only and having a default value does not conflict.
There's nothing at all broken with

def foo(!x, !y='bar'):
     pass

where !x and !y would be positional-only arguments. You can't of course
have something like

def foo(!x, !y='bar', z):
     pass

but you can't have that today either.

Georg

-- 
Thus spake the Lord: Thou shalt indent with four spaces. No more, no less.
Four shall be the number of spaces thou shalt indent, and the number of thy
indenting shall be four. Eight shalt thou not indent, nor either indent thou
two, excepting that thou then proceed to four. Tabs are right out.



More information about the Python-3000 mailing list