473,403 Members | 2,071 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,403 software developers and data experts.

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
Jun 27 '08 #1
1 1308
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: Rob Long | last post by:
Hey, I've just noticed a somewhat annoying feature with PHP5 type hinting. You cannot hint types on optional arguments like this: class MyClass { function someFunc(Type1 $arg1, Type2 $arg2...
66
by: Darren Dale | last post by:
Hello, def test(data): i = ? This is the line I have trouble with if i==1: return data else: return data a,b,c,d = test()
13
by: Madhusudan Singh | last post by:
Hi I know how to set optional arguments in the function definition. Is there an intrinsic function that determines if a certain argument was actually passed ? Like the fortran 95 present()...
4
by: Augustus S.F.X Van Dusen | last post by:
I have recently come across the following construction: #define P_VAR(output, string, args...) \ fprintf (output, "This is "string"\n", ##args) which can be invoked as follows: int x = 1,...
12
by: Nick Hounsome | last post by:
Can anyone tell me what the rational is for not supporting optional arguments. It is obviously a trivial thing to implement and, since C++ has them, I would not expect them to be omitted without...
14
by: cody | last post by:
I got a similar idea a couple of months ago, but now this one will require no change to the clr, is relatively easy to implement and would be a great addition to C# 3.0 :) so here we go.. To...
7
by: VK | last post by:
I was getting this effect N times but each time I was in rush to just make it work, and later I coudn't recall anymore what was the original state I was working around. This time I nailed the...
6
by: Rob Hoelz | last post by:
So these two functions are different: void foo(void); and void foo(); because the first one allows no arguments, but the second does. My question is: In the implementation of the...
2
ADezii
by: ADezii | last post by:
When a call is made to a Sub or Function Procedure, you can supply Arguments in the exact order they appear in the Procedure's definition, or you can supply them in any position by name. To...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.