Feature request: New string conversion type to ignore list item

T

thomas.pohl

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
 
P

Peter Otten

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:
'first third'

Peter
 
D

Dennis Lee Bieber

Why not be consistent with other aspects of the language:

"%s %!s %s" % ("first", "second", "third")

Probably because most of the formatting codes are handled by the
pre-existing C runtime library... %.s is likely interpreted by the C
runtime as "format 0 width 0 minimum string" (or something like that,
just as %5.3f is format 5 width 3 decimal float)
--
Wulfraed Dennis Lee Bieber KD6MOG
(e-mail address removed) (e-mail address removed)
HTTP://wlfraed.home.netcom.com/
(Bestiaria Support Staff: (e-mail address removed))
HTTP://www.bestiaria.com/
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,901
Latest member
Noble71S45

Latest Threads

Top