String formatters with variable argument length

Matimus mccredie at gmail.com
Thu Nov 30 20:22:55 EST 2006


> Could it be as I fear, that it is impossible?

p'shaw, you underestimate the power of the Python...

I think this is a poor solution (I would go with the solution in John
Machin's second post) but here it is anyway since it does essentially
what you asked for:

[code]
def print_data(fmtstr):
    data = (10,11,12,13)
    for i in xrange(len(data)):
        try:
            print fmtstr %data[:i+1]
            break
        except:
            pass
[/code]




More information about the Python-list mailing list