On Fri, Feb 15, 2008 at 8:46 AM, Joel Bender <[EMAIL PROTECTED]> 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. The notation you recommended just confuses the hell outa me when reading it, it is neither clean nor elegant for the stated intent, which is a method of defining positional only arguments. eg. def test([arg1=1, arg2=2,] arg3): return (arg1, arg2, arg3) assert test(9) == (1, 2, 9) assert test(7, 8, 9) == (7, 8, 9) test(8, 9) == Exception test(arg3=9) == ??? This example clearly shows what confuses me about this notation. arg1 and arg2 are supposed to be positional only, but your first example the first argument you set end up in the 3rd position for no reason other then you defined default arguments before the positional arguments, which should and does raise "SyntaxError: non-default argument follows default argument" The intent is to make it so (Assuming arg1 and arg2 are positional only) you cannot do test(arg3=9, arg1=7, arg2=8), thus you would be required to do test(7, 8, 9) {since doing test(7, 8, arg3=9) would raise an error of positional arg being set by position and keyword at the same time} _______________________________________________ Python-3000 mailing list Python-3000@python.org http://mail.python.org/mailman/listinfo/python-3000 Unsubscribe: http://mail.python.org/mailman/options/python-3000/archive%40mail-archive.com