[ python-Feature Requests-1075902 ] ignore element format character for PyArg_ParseTuple

SourceForge.net noreply at sourceforge.net
Wed Dec 15 03:49:28 CET 2004


Feature Requests item #1075902, was opened at 2004-11-30 05:28
Message generated for change (Comment added) made by rhettinger
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=355470&aid=1075902&group_id=5470

Category: None
Group: None
>Status: Closed
>Resolution: Rejected
Priority: 5
Submitted By: Sean Proctor (sproctor)
Assigned to: Nobody/Anonymous (nobody)
Summary: ignore element format character for PyArg_ParseTuple

Initial Comment:
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.

----------------------------------------------------------------------

>Comment By: Raymond Hettinger (rhettinger)
Date: 2004-12-14 21:49

Message:
Logged In: YES 
user_id=80475

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.

----------------------------------------------------------------------

Comment By: Martin v. Löwis (loewis)
Date: 2004-12-09 18:21

Message:
Logged In: YES 
user_id=21627

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.

----------------------------------------------------------------------

Comment By: Sean Proctor (sproctor)
Date: 2004-12-09 00:37

Message:
Logged In: YES 
user_id=43755

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.

----------------------------------------------------------------------

Comment By: Tim Peters (tim_one)
Date: 2004-12-09 00:04

Message:
Logged In: YES 
user_id=31435

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.

----------------------------------------------------------------------

Comment By: Sean Proctor (sproctor)
Date: 2004-12-08 22:35

Message:
Logged In: YES 
user_id=43755

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.

----------------------------------------------------------------------

Comment By: Martin v. Löwis (loewis)
Date: 2004-12-08 16:42

Message:
Logged In: YES 
user_id=21627

What's wrong with using O as the format character?

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=355470&aid=1075902&group_id=5470


More information about the Python-bugs-list mailing list