Error in the book on format specifiers?
In the book Beginning Python by James Payne it says "Whenever you right a negative (-) in your format specifier, the format occurs to the left of the word. If there is just a number with no negative it occurs to the right". )
Well.... I must not understand what he means, or there must be an error in his writing. When I type the first example with the negative, it moves to the right. In the second, it moves to the left.
I also noticed that he wrote right instead of write, so this whole sentence might be an error.
>>> "%-30s %s" % ("Hello", "Hi")
'Hello______________________________Hi'
>>> "%30s %s" % ("Hello", "Hi")
'______________________________Hello Hi'
The underlines represent spaces, the spaces don't show on the post if I don't underline the area.
|