On 08/17/2010 10:28 AM, Stefan Schwarzer wrote:
Hi Neil,

On 2010-08-17 14:42, Neil Cerutti wrote:
On 2010-08-17, Michael Torrie<torr...@gmail.com>  wrote:
In general if I find myself consistently going longer than 75
or 80 characters, I need to refactor my code to make it more
manageable.  If I have to scroll up five pages to find the
beginning of a block, that normally means my code could be
simplified and improved.

Looking through my code, the split-up lines almost always include
string literals or elimination of meaningless temporary
variables, e.g.:

         self.expiration_date = translate_date(find(response,
             'MPNExpirationDate').text, '%Y-%m-%d', '%m%d%Y')

I'd probably reformat this to

           self.expiration_date = translate_date(
             find(response, 'MPNExpirationDate').text,
             '%Y-%m-%d', '%m%d%Y')

or even

           self.expiration_date = translate_date(
             find(response, 'MPNExpirationDate').text,
             '%Y-%m-%d',
             '%m%d%Y')

for consistency.

This not only limits the width but also makes the nesting of
the calls more visible.

Stefan

Doesn't this create the problem of functions growing too long to fit in
a screen? I think it's very useful to try to keep function size low
enough so that you can view the whole function without having to scroll
up and down. (even though that's not always possible) -ak
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to