what does the % mean in lines of code such as this http://dpaste.com/607203/
The item in demolist replaces the % sign. The % tells the function to insert whatever was given to it, in this case each item in demolist.
In Python, the % symbol is used in print to introduce a format specifier (more commonly known as a conversion specifier) and also as a formatting or interpolation operator . http://en.wikipedia.org/wiki/Printf#1990s:_PHP.2C_Python It's used in the printf class of functions in several different programming languages. In Python it's used like this: print "%s and %s." % ('Spam', 'Eggs') which outputs: >> Spam and Eggs. you supply print with a format string containing conversion specifiers like %s inside it (there are many other conversion specifiers like %d and %f and %x etc. %s is a conversion specifier that converts an object into a string and inserts it into the format string when it is rendered and printed into the output stream). print '%s and %s.' In Python, you must use the % operator between the format string and a tuple containing the objects you want to render inside the format string. I want to print out Spam and Eggs so I use the tuple ('Spam', 'Eggs') containing two strings, 'Spam', and 'Eggs'. print '%s and %s.' % ('Spam', 'Eggs') http://docs.python.org/library/stdtypes.html contains a list of conversion specifiers you may use with print. You can combine many options with conversion specifiers. For example: hours = 3 minutes = 15 seconds = 0 print "%.2d:%.2d:%.2d" % (hours, minutes, seconds) outputs: >> 03:15:00 I included .2 in the %d conversion specifier to make the program print at least 2 digits per decimal number.
Join our real-time social learning platform and learn together with your friends!