473,408 Members | 1,826 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,408 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 1296
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: 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: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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,...

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.