[Python-ideas] Treat underscores specially in argument lists

Ryan Gonzalez rymg19 at gmail.com
Tue Feb 17 02:23:30 CET 2015


Often, underscores are used in function argument lists:

def f(_): pass

However, sometimes you want to ignore more than one argument, in which case
this doesn't work:

ryan at DevPC-LX:~$ python3
Python 3.4.1 |Anaconda 2.1.0 (64-bit)| (default, Sep 10 2014, 17:10:18)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-1)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> def f(_, _): pass
...
  File "<stdin>", line 1
SyntaxError: duplicate argument '_' in function definition
>>>

My idea is to allow duplication of the underscore argument in the
presumption that no one in their right (or wrong) mind is going to use it
as a real argument, and, if someone does, they need to be slapped on the
head.

-- 
Ryan
If anybody ever asks me why I prefer C++ to C, my answer will be simple:
"It's becauseslejfp23(@#Q*(E*EIdc-SEGFAULT. Wait, I don't think that was
nul-terminated."
Personal reality distortion fields are immune to contradictory evidence. -
srean
Check out my website: http://kirbyfan64.github.io/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20150216/6d6ba557/attachment.html>


More information about the Python-ideas mailing list