How to modify this script?

Chris Angelico rosuav at gmail.com
Sun Jan 6 08:44:13 EST 2013


On Mon, Jan 7, 2013 at 12:34 AM, Kurt Hansen <kurt at ugyldig.invalid> wrote:
> "innermost"? I have replaced this with yours, but all the marked text are
> deleted:

Here's the full code, with my change:

$<
lines = $GEDIT_SELECTED_TEXT.split("\n");
output = '<table\>\n';

for line in lines:
        output += '<tr\>';

        columns = line.split("\t");
        for item in columns:
                output += '<td colspan="' + (4-len(columns)) + '"\>' +
item + '</td\> '

        output += '</tr\>\n';

output += '</table\>';
return output
>

It's only one line of code that needs to be changed. Python loops (and
other control structures) are defined by indentation, so the innermost
loop is the one that starts furthest to the right.

Chris Angelico



More information about the Python-list mailing list