> ...  print '%*s --> %*s' % (maxKey, name, maxValue, pairs[name])
> 
> thanks for pointing out the '*' syntax. Ignorant as I am I have 
> had to write things like
>
>   print '%%%ss --> %%%ss' % (maxKey, maxValue) % (name, pairs[name])

I didn't even try that, I've always done it on two lines

fmt = "%%%ds --> %%%ds' % (width1,width2)
print fmt % (value1,value2)

'%*s' is a neat trick, albeit a tad obscure in the readability stakes.
But is %%%ds any better?!

Alan G.

_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to