79 chars or more?

Jean-Michel Pichavant jeanmichel at sequans.com
Wed Aug 18 10:57:00 CEST 2010


D'Arcy J.M. Cain wrote:
> On Tue, 17 Aug 2010 16:28:02 +0200
> Stefan Schwarzer <sschwarzer at sschwarzer.net> wrote:
>   
>> 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')
>>     
>
> You can extend this if there are complicated sub-calls.  Probably
> overkill for this example but here is the idea.
>
>            self.expiration_date = translate_date(
>              find(
>                response,
>               'MPNExpirationDate',
>              ).text,
>              '%Y-%m-%d',
>              '%m%d%Y'
>            )
>
> I also moved the closing brace down to align with the line that opened
> that block.
>
>   
If this is supposed to convice 80+ chars users, that's an epic failure :)
This is exactly the kind of layout I'm happy to not use by not caring 
about the line width.

At least, if you still want to stick with 79 chars, do something like

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

JM



More information about the Python-list mailing list