Note that lots of pages on Zope.org make the presumption that you're browsing at a screen resolution of 1024 x 768 or higher. It's unfortunately very difficult to accomodate lower resolutions and still be able to give example code mixed with narrative in any reasonable way. Note that the "standard" for Zope Python code is 79 characters wide *wihtout* \'s. When combined with a buffer on the left hand side, I can imagine the result running over 800 pixels. 120 characters is absurd, though, you're right. This is a problem with Python code in general. Lots of times I end up breaking semantics across lines for this reason. ----- Original Message ----- From: "Paul Winkler" <slinkp23@yahoo.com> To: <zope@zope.org> Sent: Tuesday, November 20, 2001 12:51 PM Subject: Re: [Zope] Line Wrap and the Zope Community?
On Tue, Nov 20, 2001 at 11:41:35AM -0500, Chris McDonough wrote:
This particular case is fixed.
I don't know what it looked like before, but the text still goes off the screen a bit on Netscape 4.74, linux, 800x600 display.
The cause? Long lines in the code examples, which of course are in <pre> tags and can't be wrapped. This causes the whole table to be as wide as the largest line in a <pre> tag. In this case, the examples aren't that long but for some reason there are 6 unnecessary blank spaces in front of each line. Maybe a stx issue?
I see this problem all over pages on Zope.org. Very often it's due to people posting sloppy code examples with very long lines. I've seen some code examples with a single line that's 120 characters long. People, please don't do that! Not only does it make your web pages scroll off to the right, it makes your code harder to read and understand, which is not nice to the newbies.
For example, browsing through the links from the first page of http://www.zope.org/Documentation/nuser: at least half of them have this problem. Some are very hard to read. Here's a particularly long line:
if search_expr=='' or string.find(string.lower(o.raw),string.lower(search_expr)) != -1 or string.find(string.lower(des),string.lower(search_expr)) != -1 or string.find(string.lower(title),string.lower(search_expr)) != -1 :
Simply break up the lines and it's much nicer, like this:
if search_expr=='' or \ string.find(string.lower(o.raw), string.lower(search_expr)) != -1 or \ string.find(string.lower(des), string.lower(search_expr)) != -1 or \ string.find(string.lower(title), string.lower(search_expr)) != -1 : ...
Also, there's a lot of redundancy... do we need to say string.lower(search_expr) three times? No. Assign it to a new variable. In this case, search_expr was never used again so we can simply reuse the name search_expr, like so:
search_expr = string.lower(search_expr) if search_expr=='' or \ string.find(string.lower(o.raw), search_expr) != -1 or \ string.find(string.lower(des), search_expr) != -1 or \ string.find(string.lower(title), search_expr) != -1 : ...
Another variation... at this point it's definitely a matter of taste (and maybe optimization):
from string import find, lower search_expr = lower(search_expr) if search_expr=='' or \ find(lower(o.raw), search_expr) != -1 or \ find(lower(des), search_expr) != -1 or \ find(lower(title), search_expr) != -1 : ...
--
paul winkler home: http://www.slinkp.com music: http://www.reacharms.com calendars: http://www.calendargalaxy.com
_______________________________________________ Zope maillist - Zope@zope.org http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )