Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   Python (http://www.velocityreviews.com/forums/f43-python.html)
-   -   extra positional arguments before optional parameters syntax (http://www.velocityreviews.com/forums/t621039-extra-positional-arguments-before-optional-parameters-syntax.html)

MisterWilliam 06-18-2008 09:25 PM

extra positional arguments before optional parameters syntax
 
I noticed that in PEP 3105, the PEP about turning print to print(),
the syntax for print() is defined as follows:
def print(*args, sep=' ', end='\n', file=None)

Ignoring the fact that print is a reserved keyword in python, this is
not valid python because extra positional arguments (*args), cannot
come before optional parameters (sep=' ', end='\n', file=None).

>>> def f(*args, sep=' ', end='\n', file=None):

File "<stdin>", line 1
def f(*args, sep=' ', end='\n', file=None):
^
SyntaxError: invalid syntax

Am I misunderstanding something? Is this type of syntax suppose to be
allowed in a future version of Python? (I can't find anything about
this through my searching.) This kind of syntax seems useful,
especially one wants to overwrite the new function print().

Thanks,
William Chang

George Sakkis 06-18-2008 09:34 PM

Re: extra positional arguments before optional parameters syntax
 
On Jun 18, 5:25 pm, MisterWilliam <mr.williamch...@gmail.com> wrote:

> I noticed that in PEP 3105, the PEP about turning print to print(),
> the syntax for print() is defined as follows:
> def print(*args, sep=' ', end='\n', file=None)
>
> Ignoring the fact that print is a reserved keyword in python, this is
> not valid python because extra positional arguments (*args), cannot
> come before optional parameters (sep=' ', end='\n', file=None).
>
> >>> def f(*args, sep=' ', end='\n', file=None):

>
> File "<stdin>", line 1
> def f(*args, sep=' ', end='\n', file=None):
> ^
> SyntaxError: invalid syntax
>
> Am I misunderstanding something? Is this type of syntax suppose to be
> allowed in a future version of Python? (I can't find anything about
> this through my searching.)


You didn't search hard enough; it's three PEPs earlier:

http://www.python.org/dev/peps/pep-3102/

George


All times are GMT. The time now is 05:19 AM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.