472,951 Members | 1,727 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

Feature request: New string conversion type to ignore list item

Hi,
let's assume you want to nicely print the content of a list except for
one (or some)
individual item. You could do it like this:

t = ["foo", "skip me", 1, 2, 3]
print("text: %s\nvalues: %i %i %i" % (t[0], t[2], t[3], t[4]))

If there was a conversion type which simply ignores the corresponding
list item
- let's call it "%v" like "void" - things would be much easier:

t = ["foo", "skip me", 1, 2, 3]
print("text: %s\nvalues: %v%i %i %i" % t)

I guess that this new conversion type wouldn't break any existing
code.
What do you think?

Cheers,
Tom

Jun 5 '07 #1
4 1275
th*********@gmail.com wrote:
let's assume you want to nicely print the content of a list except for
one (or some) individual item. You could do it like this:
t = ["foo", "skip me", 1, 2, 3]
print("text: %s\nvalues: %i %i %i" % (t[0], t[2], t[3], t[4]))
or like this:
>>"%s %.s %s" % ("first", "second", "third")
'first third'

Peter
Jun 5 '07 #2
On 5 Jun., 13:12, Peter Otten <__pete...@web.dewrote:
or like this:
>"%s %.s %s" % ("first", "second", "third")

'first third'
Hey, that's great, thanks Peter!

Tom

Jun 5 '07 #3
On Jun 5, 6:27 am, thomas.p...@gmail.com wrote:
On 5 Jun., 13:12, Peter Otten <__pete...@web.dewrote:
or like this:
>>"%s %.s %s" % ("first", "second", "third")
'first third'

Hey, that's great, thanks Peter!

Tom
Why not be consistent with other aspects of the language:

"%s %!s %s" % ("first", "second", "third")
Jun 12 '07 #4
pelon wrote:
On Jun 5, 6:27 am, thomas.p...@gmail.com wrote:
>On 5 Jun., 13:12, Peter Otten <__pete...@web.dewrote:
>>or like this:
>"%s %.s %s" % ("first", "second", "third")
'first third'
Hey, that's great, thanks Peter!

Tom

Why not be consistent with other aspects of the language:

"%s %!s %s" % ("first", "second", "third")
You may be interested in the Python 3000 plans, where this is written::

'{0} {2}'.format('first', 'second', 'third')

http://www.python.org/dev/peps/pep-3101/

STeVe
Jun 12 '07 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

30
by: Raymond Hettinger | last post by:
Proposal -------- I am gathering data to evaluate a request for an alternate version of itertools.izip() with a None fill-in feature like that for the built-in map() function: >>> map(None,...
12
by: Raymond Hettinger | last post by:
I am evaluating a request for an alternate version of itertools.izip() that has a None fill-in feature like the built-in map function: >>> map(None, 'abc', '12345') # demonstrate map's None...
0
by: jts2077 | last post by:
I am trying to create a large nested XML object using E4X methods. The problem is the, the XML I am trying to create can only have xmlns set at the top 2 element levels. Such as: <store ...
10
by: Conrad Lender | last post by:
In a recent thread in this group, I said that in some cases object detection and feature tests weren't sufficient in the development of cross-browser applications, and that there were situations...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
0
by: Mushico | last post by:
How to calculate date of retirement from date of birth
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 4 Oct 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: Aliciasmith | last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
2
by: giovanniandrean | last post by:
The energy model is structured as follows and uses excel sheets to give input data: 1-Utility.py contains all the functions needed to calculate the variables and other minor things (mentions...
1
by: Teri B | last post by:
Hi, I have created a sub-form Roles. In my course form the user selects the roles assigned to the course. 0ne-to-many. One course many roles. Then I created a report based on the Course form and...
3
by: nia12 | last post by:
Hi there, I am very new to Access so apologies if any of this is obvious/not clear. I am creating a data collection tool for health care employees to complete. It consists of a number of...
0
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be focusing on the Report (clsReport) class. This simply handles making the calling Form invisible until all of the Reports opened by it have been closed, when it...

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.