79 chars or more?
Roald de Vries
downaold at gmail.com
Thu Aug 19 10:42:32 EDT 2010
Dear Jean-Michel,
On Aug 18, 2010, at 10:57 AM, Jean-Michel Pichavant wrote:
> 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')
I don't necessarily like this example *so* much. I have no real
problem with it, and maybe would write it myself sometimes, but I'm
curious what people think of the following reasoning.
I think that, for optimal readability, variable names should reflect
the role if the function/class/module of the variable they refer to.
If you stick to this convention, a function can normally be read very
easily by just scanning through the left part of assignment
statements. In your case, it looks like text would better be called
expiration_text, or something like that. But what I would like better,
is:
self.expiration_date = translate_date(
text = find(response, 'MPNExpirationDate', ).text,
format1 = '%Y-%m-%d', # I don't know the argument name
format2 = '%m%d%Y', # ... and of this one neither
)
Moreover, the 'text = ...'-like statement, that are only used in the
one statement after it, often interrupt a (more) logical sequence of
variable assignments, and make your program a bit less readable.
Cheers, Roald
More information about the Python-list
mailing list