pep8 - python: how should I write very long lines of code? -
If I have a long line of code, is it possible to continue it on the next line: / P>
url = 'http: //chart.apis.google.com/chart? Chxl = 1: | 0 | 10 | 100 | 1,000 | 10,000 | ' + '100,000 | 1,000,000 and CXP = 1,0 and CXR = 0,0, '+ Maximum (Freak) +' 300 | 1,0,3 and Caxs = 0,676767,13.5,0, L, 676767. 1, 676767,13.5,0, L, 676767 & amp; Chxt = y, x & amp; Chbh = a, 1,0 and chs = 640x465 and cht = BVS & amp; Chco = A2C180 & amp; Chds = 0,300 & amp;
I will write it like this
Code> url = ('http: //chart.apis.google.com/chart?chxl=1: | 0 | 10 | 100 | 1,000 | 10,000 |' '100,000 | 1,000,000 & amp; chxp = 1,0 & amp; ; Chxr = 0,0,% (Max_freq) s300 | 1,0,3 and chxs = 0,676767 '', 13.5,0, L, 676767 | 1,676767,13.5,0, L, 676767, and chakk = y , X and PHH = A, 1, 0 & amp; chs = 640x465 '' and amp; cht = BVS & amp; chco = A2C180 & amp; chds = 0,300 & chd = t: '% {' max_freq ':' Maximum (freq)})
Note that to join the string, +
is not required. This is better than this because the strings are included in the compile of time instead of the runtime.
I have embedded % (max_freq) s
in your string, it has been replaced with dict
at the end
Also see if you want to simplify your URL
Comments
Post a Comment