On Tue, May 6, 2008 at 2:35 PM, Dick Moores <[EMAIL PROTECTED]> wrote:
> I'm lost here. That '*'
> is just too magical.. Where did you guys learn about '%*s'?
http://docs.python.org/lib/typesseq-strings.html
Item 4 - Minimum field width
> Does the '%s'
> still mean a string?
Yes.
OK. Got it, finally.
The script has become < http://py77.python.pastebin.com/f604c64de> (I need to wrap lines 18 and 58).
The function is now:
def printResult(date1, date2, days1, weeks, days2):
print "\nThe difference between %s and %s is %d days" % (date1.strftime("%m/%d/%Y"),
date2.strftime("%m/%d/%Y"), days1)
line1 = "\nThe difference between %s and %s is %d days" % ((date1.strftime("%m/%d/%Y"), date2.strftime("%m/%d/%Y"), days1))
line2 = "Or %d weeks and %d days" % (weeks, days2)
print '%*s' % ((len(line1) -1), line2)
print (len(line1) -1) * "="
And works perfectly.
Thanks very much.
Dick
_______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor