By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
464,590 Members | 1,025 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 464,590 IT Pros & Developers. It's quick & easy.

extra positional arguments before optional parameters syntax

P: n/a
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
Jun 27 '08 #1
Share this Question
Share on Google+
1 Reply

P: n/a
On Jun 18, 5:25 pm, MisterWilliam <mr.williamch...@gmail.comwrote:
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
Jun 27 '08 #2

This discussion thread is closed

Replies have been disabled for this discussion.