Writing long lines of code
There are many times when we need to write lines of code that are so long that they're very hard to read. Many people like to limit the length of a line of code to 80 characters or fewer. It's a well-known principle of graphic design that a narrower line is easier to read; opinions vary, but 65 characters is often cited as ideal. See http://webtypography.net/2.1.2.
While shorter lines are easier on the eyes, our code can refuse to cooperate with this principle. Long statements are a common problem. How can we break long Python statements into more manageable pieces?
Getting ready
Often, we'll have a statement that's awkwardly long and hard to work with. Let's say we've got something like this:
>>> import math>>> example_value = (63/25) * (17+15*math.sqrt(5)) / (7+15*math.sqrt(5))>>> mantissa_fraction, exponent = math.frexp(example_value)>>> mantissa_whole = int(mantissa_fraction*2**53)>>> message_text = 'the internal representation...