Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #36252

Re: How to modify this script?

Path csiph.com!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!newsfeed.xs4all.nl!newsfeed4.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <rosuav@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.000
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'output': 0.04; 'line:': 0.07; 'skip:$ 30': 0.07; 'subject:How': 0.09; 'deletes': 0.09; 'editor.': 0.09; 'lines:': 0.09; 'snippet': 0.09; 'subject:script': 0.09; 'wraps': 0.09; 'bug': 0.10; 'kurt': 0.11; "'';": 0.16; 'ah,': 0.16; 'chris,': 0.16; 'columns': 0.16; 'commented': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'unwrap': 0.16; 'mon,': 0.16; 'wrote:': 0.17; 'jan': 0.18; '(or': 0.18; 'work.': 0.23; 'header:In-Reply-To:1': 0.25; 'am,': 0.27; 'message-id:@mail.gmail.com': 0.27; 'fixed': 0.28; 'lines': 0.28; 'received:209.85.212': 0.28; "i'm": 0.29; 'code': 0.31; 'that!': 0.33; 'version:': 0.33; 'to:addr:python- list': 0.33; 'version': 0.34; 'received:google.com': 0.34; 'text': 0.34; 'subject:?': 0.35; 'received:209.85': 0.35; 'but': 0.36; 'should': 0.36; 'why': 0.37; 'item': 0.37; 'received:209': 0.37; 'subject:: ': 0.38; 'to:addr:python.org': 0.39; 'header:Received:5': 0.40; 'your': 0.60; "you'll": 0.62; 'applying': 0.69; 'subject:this': 0.84; '2013': 0.84
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; bh=Ww++zJdtboekjhjdPsSCmAQlW0KcQ9WruHqaB+3aNXU=; b=T/sfwnfEMUlucGscQTJioUg6pMQ/gnBQH36yFpKAJ137HzKax54PemqRx9ugkLgeYE Tqi107Lr0mCAaaoOyHfBs32WmOcXT0CxJN9rQD/B+NF7Rt4fJX8XK3zF8A5y2FXxRXqq 7J/eh+tPow4n8/s7Vlshv1tmYonhG4NKHadiaLDZZ0kAG5QxajKPUL9TeE30Wmsm9MOQ Miyh0aF7kR6rTZIitYskUytgH1vv+TFoqPFhovE3RUZBALgQat+cQ9nnivTpbjogSHeq X7mBa/SpZp7v70nz/PpXhrmmgwJyG4x7hXxviSQ+GP5IKquBYqAPPEmC6FpWK1ov+Ppz TMpA==
MIME-Version 1.0
In-Reply-To <50e9844f$0$294$14726298@news.sunsite.dk>
References <50e97123$0$294$14726298@news.sunsite.dk> <mailman.160.1357476725.2939.python-list@python.org> <50e97d82$0$294$14726298@news.sunsite.dk> <mailman.167.1357479855.2939.python-list@python.org> <50e9844f$0$294$14726298@news.sunsite.dk>
Date Mon, 7 Jan 2013 01:20:25 +1100
Subject Re: How to modify this script?
From Chris Angelico <rosuav@gmail.com>
To python-list@python.org
Content-Type text/plain; charset=ISO-8859-1
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.169.1357482034.2939.python-list@python.org> (permalink)
Lines 37
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1357482034 news.xs4all.nl 6966 [2001:888:2000:d::a6]:43207
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:36252

Show key headers only | View raw


On Mon, Jan 7, 2013 at 1:03 AM, Kurt Hansen <kurt@ugyldig.invalid> wrote:
> I'm sorry to bother you, Chris, but applying the snippet with your code in
> Gedit still just deletes the marked, tab-separated text in the editor.

Ah, whoops. That would be because I had a bug in the code (that's why
I commented that it was untested). Sorry about that! Here's a fixed
version:

$<
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="' + str(4-len(columns)) +
'"\>' + item + '</td\> '

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

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


Note that it's a single line:

output += '<td colspan="' + str(4-len(columns)) + '"\>' + item + '</td\> '

If your newsreader (or my poster) wraps it, you'll need to unwrap that
line, otherwise you'll get an IndentError.

That version should work.

ChrisA

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

How to modify this script? Kurt Hansen <kurt@ugyldig.invalid> - 2013-01-06 13:42 +0100
  Re: How to modify this script? Chris Angelico <rosuav@gmail.com> - 2013-01-06 23:52 +1100
    Re: How to modify this script? Kurt Hansen <kurt@ugyldig.invalid> - 2013-01-06 14:34 +0100
      Re: How to modify this script? Chris Angelico <rosuav@gmail.com> - 2013-01-07 00:44 +1100
        Re: How to modify this script? Kurt Hansen <kurt@ugyldig.invalid> - 2013-01-06 15:03 +0100
          Re: How to modify this script? Chris Angelico <rosuav@gmail.com> - 2013-01-07 01:20 +1100
            Re: How to modify this script? Kurt Hansen <kurt@ugyldig.invalid> - 2013-01-06 15:30 +0100
              Re: How to modify this script? Chris Angelico <rosuav@gmail.com> - 2013-01-07 01:41 +1100
              Re: How to modify this script? Thomas Rachel <nutznetz-0c1b6768-bfa9-48d5-a470-7603bd3aa915@spamschutz.glglgl.de> - 2013-01-08 15:18 +0100
                Re: How to modify this script? Kurt Hansen <kurt@ugyldig.invalid> - 2013-01-09 10:21 +0100
  Re: How to modify this script? chaouche yacine <yacinechaouche@yahoo.com> - 2013-01-06 04:58 -0800
    Re: How to modify this script? Kurt Hansen <kurt@ugyldig.invalid> - 2013-01-06 14:38 +0100
      Re: How to modify this script? chaouche yacine <yacinechaouche@yahoo.com> - 2013-01-06 06:01 -0800
        Re: How to modify this script? Kurt Hansen <kurt@ugyldig.invalid> - 2013-01-06 15:21 +0100
          Re: How to modify this script? chaouche yacine <yacinechaouche@yahoo.com> - 2013-01-06 07:12 -0800
            Re: How to modify this script? Kurt Hansen <kurt@ugyldig.invalid> - 2013-01-07 17:42 +0100
              Re: How to modify this script? chaouche yacine <yacinechaouche@yahoo.com> - 2013-01-08 07:31 -0800
                Re: How to modify this script? Kurt Hansen <kurt@ugyldig.invalid> - 2013-01-09 10:07 +0100
                Re: How to modify this script? chaouche yacine <yacinechaouche@yahoo.com> - 2013-01-09 02:23 -0800
                Re: How to modify this script? Kurt Hansen <kurt@ugyldig.invalid> - 2013-01-09 12:04 +0100
                Re: How to modify this script? chaouche yacine <yacinechaouche@yahoo.com> - 2013-01-09 10:25 -0800
                Re: How to modify this script? Kurt Hansen <kurt@ugyldig.invalid> - 2013-01-11 05:35 +0100
  Re: How to modify this script? Subimal Deb <subimal.deb@gmail.com> - 2013-01-06 06:22 -0800
    Re: How to modify this script? Kurt Hansen <kurt@ugyldig.invalid> - 2013-01-06 15:40 +0100
      Re: How to modify this script? Chris Angelico <rosuav@gmail.com> - 2013-01-07 01:52 +1100
        Re: How to modify this script? Kurt Hansen <kurt@ugyldig.invalid> - 2013-01-06 16:05 +0100
  Re: How to modify this script? Gertjan Klein <gklein@xs4all.nl> - 2013-01-07 18:56 +0100
    Re: How to modify this script? Thomas Rachel <nutznetz-0c1b6768-bfa9-48d5-a470-7603bd3aa915@spamschutz.glglgl.de> - 2013-01-08 15:22 +0100
      Re: How to modify this script? Gertjan Klein <gklein@xs4all.nl> - 2013-01-08 17:22 +0100

csiph-web