---------- Original Message ------------- Subject: Re: [Tutor] Numbers & Characters As Dictionary Keys Date: Tue, 21 Jun 2005 17:47:41 +0100 From: "Alan G" <[EMAIL PROTECTED]> To: "Don Parris" <[EMAIL PROTECTED]>, "Python Tutor List" <tutor@python.org>
> > print "%s\t%s" % (m,menu[m][0]) > > > I am curious what the "%" by itself is doing. Its a standard string formatting operation in Python. The % operator basically says substitute the values in the folowing tuple for the marked fields in the foregoing string. The print statement above therefore is roughly equivalent to: print m + '\t' + menu[m][0] But the formatting markers allow you to add formatting data like the minimum number of characters, right/left justification, number of digits after a decimal point, hex or decimal display of numbers etc etc. Take a look in the Python docs for string formatting. I was able to understand the '\t' and the '%s'. It was that lone % sign that made it look weird to me. I will be digging into the string formatting stuff, for sure. I'm hoping to produce an output format that will be acceptable for certain organizations. When I cannot focus on the MySQL portion of this app, I'll be focusing on the other aspects. I seem to be able to build simple functions. It's when I want to reduce the amount of code I have to write that I start running into issues. :) Don _______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor