This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Title: ignore element format character for PyArg_ParseTuple
Type: enhancement Stage:
Components: None Versions:
Status: closed Resolution: rejected
Dependencies: Superseder:
Assigned To: Nosy List: loewis, rhettinger, sproctor, tim.peters
Priority: normal Keywords:

Created on 2004-11-30 10:28 by sproctor, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Messages (7)
msg54317 - (view) Author: Sean Proctor (sproctor) Date: 2004-11-30 10:28
Some kind of option to indicate there is an element,
but we don't care about its value would be nice. It
could be _. then an example would be:
PyArg_ParseTuple (tuple, "_i", &my_int);

This indicates that there is another value before the
int, but we don't care about it one way or the other.
msg54318 - (view) Author: Martin v. Löwis (loewis) * (Python committer) Date: 2004-12-08 21:42
Logged In: YES 

What's wrong with using O as the format character?
msg54319 - (view) Author: Sean Proctor (sproctor) Date: 2004-12-09 03:35
Logged In: YES 

If I use O, then I need to have a variable to store it in. I
think it's less readable. Like with pattern matching in ML,
you can use a variable instead of _, but it's not obvious
that you aren't going to use that value. With some kind of
place holder, this is made clear, and I don't need to create
a variable to store a value that I don't care about.
msg54320 - (view) Author: Tim Peters (tim.peters) * (Python committer) Date: 2004-12-09 05:04
Logged In: YES 

If you want to make C code look like ML, declare

PyObject** _;

and use _ in the argument list.

I'm -1 on this:  the case has almost never arisen in my 
experience, and the limited pool of format characters should 
be preserved for high-value uses.
msg54321 - (view) Author: Sean Proctor (sproctor) Date: 2004-12-09 05:37
Logged In: YES 

that would turn my example into PyArg_ParseTuple (tuple,
"Oi", _, &my_int);

I don't particularly care. I thought it was a good
suggestion. To me _ looks like a blank. I wouldn't really
want to use it in a format string for something besides an
any/none scenario. Your reasoning about preserving format
characters seems really weak.

You've never had a tuple where you didn't care about the
value of each element?

Somewhat separate topic. Could you say "PyArg_ParseTuple
(tuple, "Oi", NULL, &my_int);" ? I guess that would be a
less elegant way of doing what I intended.
msg54322 - (view) Author: Martin v. Löwis (loewis) * (Python committer) Date: 2004-12-09 23:21
Logged In: YES 

So just call the variable _:

PyObject *_;

PyArg_ParseTuple(tuple, "Oi", &_, &my_int);

Given that this is possible today already, I expect that
this RFE will be considered so minor that it won't be
implemented anytime soon. It increases the learning curve
for a nearly-unnoticable convenience.
msg54323 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2004-12-15 02:49
Logged In: YES 

Am closing this RFE.  It has a -1 from three developers.  The 
benefits, if any, are minor and do not warrant the time to 
implement, test, document, etc.
Date User Action Args
2022-04-11 14:56:08adminsetgithub: 41247
2004-11-30 10:28:33sproctorcreate