Python syntax wart
Stefan Behnel
stefan.behnel-n05pAM at web.de
Sun Sep 9 06:10:05 EDT 2007
Lawrence D'Oliveiro wrote:
> In message <46E390B7.2080808 at web.de>, Stefan Behnel wrote:
>
>> He means he has to use backslashes instead of parentheses here.
>>
>> Which is not true, you could easily rephrase this as:
>>
>> for link in GetEachRecord(
>> "links",
>> ....):
>> out.write(
>> ....
>> )
>>
>> See? No backslash!
>
> But then you can no longer use indentation to display the two-dimensional
> structure of the statement.
Not sure what you mean here, but most people wouldn't write such code anyway.
You could easily split it up as
def format_record(record):
return "<P..." % (
record[...],
record[...])
link_records = GetEachRecord(
...
)
for record in link_records:
out.write(format_record(record))
Which reads much better IMHO.
Stefan
More information about the Python-list
mailing list