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


Groups > comp.lang.python > #36436

Re: How to modify this script?

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.freenet.ag!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <yacinechaouche@yahoo.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.001
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'python,': 0.02; 'interpreter': 0.04; 'output': 0.04; 'modify': 0.05; 'convention.': 0.07; 'works.': 0.07; 'subject:How': 0.09; 'python': 0.09; '"%s"': 0.09; '%s\\n"': 0.09; ':-(': 0.09; 'answering': 0.09; 'script,': 0.09; 'subject:script': 0.09; 'def': 0.10; 'kurt': 0.11; 'columns': 0.16; 'item)': 0.16; 'rewriting': 0.16; 'script?': 0.16; 'wrote:': 0.17; '>>>': 0.18; 'putting': 0.20; 'to:name:python-list@python.org': 0.20; 'trying': 0.21; '&gt;&gt;&gt;': 0.22; 'skip:$ 20': 0.22; 'skip:% 10': 0.22; 'sorry,': 0.22; 'help.': 0.22; '&gt;': 0.23; 'monday,': 0.23; 'to:2**1': 0.23; 'somewhere': 0.24; 'script': 0.24; 'header:In- Reply-To:1': 0.25; 'skip:" 20': 0.26; 'question': 0.27; 'lines': 0.28; 'run': 0.28; 'received:98.138.87': 0.29; 'url:mailman': 0.29; 'skip:& 10': 0.29; "i'm": 0.29; 'worked': 0.30; 'code': 0.31; 'url:python': 0.32; 'file': 0.32; 'running': 0.32; 'skip:_ 30': 0.32; 'print': 0.32; 'url:listinfo': 0.32; 'surely': 0.33; 'to:addr:python-list': 0.33; 'skip:& 20': 0.33; 'that,': 0.34; "can't": 0.34; 'text': 0.34; 'reply-to:addr:yahoo.com': 0.34; 'table': 0.35; 'subject:?': 0.35; 'subject:': 0.36; 'url:org': 0.36; 'apple': 0.36; 'data.': 0.36; 'email addr:python.org': 0.36; "i'll": 0.36; 'should': 0.36; 'thank': 0.36; 'does': 0.37; 'item': 0.37; 'sent:': 0.37; 'subject:: ': 0.38; 'green': 0.38; 'from:': 0.38; 'skip:l 20': 0.38; 'to:addr:python.org': 0.39; 'skip:" 10': 0.40; 'help': 0.40; 'url:mail': 0.40; 'your': 0.60; 'you.': 0.61; 'containing': 0.61; 'side': 0.61; 'email name:python-list': 0.62; 'between': 0.63; 'price': 0.66; 'header:Reply-To:1': 0.68; 'business': 0.70; 'received:41': 0.73; 'subject:this': 0.84; '2013': 0.84; 'fortunately': 0.84; 'yourself?': 0.84; 'received:98.138.226': 0.91
X-Yahoo-Newman-Property ymail-3
X-Yahoo-Newman-Id 350976.35817.bm@omp1004.mail.ne1.yahoo.com
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s1024; t=1357659101; bh=Rr/kWQod4f0fA1gckczqefyTOCh0QSfJXYbj1BfaBP4=; h=X-YMail-OSG:Received:X-Rocket-MIMEInfo:X-Mailer:References:Message-ID:Date:From:Reply-To:Subject:To:In-Reply-To:MIME-Version:Content-Type; b=mC+vldYOVZRk0dT979c8w7KN7SbJDms+bFolfpnpvgZO0TNlRBpJWW+Ci7GwsVx8HjaZ5dwS3SgHwgv8uJMYWJwQIUAUNpF+EQU21LQVO+ustl3TkWJWBioid2WoZVXv42HA4dlTuaMC2eFpJQNOqkS1xKVPUtJn+aUek7/s8pc=
DomainKey-Signature a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.com; h=X-YMail-OSG:Received:X-Rocket-MIMEInfo:X-Mailer:References:Message-ID:Date:From:Reply-To:Subject:To:In-Reply-To:MIME-Version:Content-Type; b=R3IFf8wBYFA2MoT7YDhKVPIvz8/VZsw4eGA2UEPMxMOgzv/ocqjMEiJ7JvcYCIKKxqIB/iEHtRGI3uVHgeNQfUBodYoykcXLp43sAhqF5TASQJ2uTewkYzkBDiv/dZ9sCC6ooSBb2qPg3spxL0PZgsDq2ZKuKWd+dVo3k+z96K4=;
X-YMail-OSG KLzZHToVM1kR3AXfIKm6LYioGub.RrOY_yfzdVSsOR_ZB0p z2wtZW3n43nwpdcKU2Q6Iv_B.gSwtlLYtY6hoQfpWjWQ1JR5_ZdvcIpKpElZ isLTEH8b4FOagYGjAnPsNZv5vwQoMvIFAWX62Lt7eLacYCOyvtkO8VQlDF9s HjYxkPKKhhQAL6ygk9c2FSHN5mbqBiarGBAhQbqxV28CNl9Db4ZxgHnfMaAn a.M5ulnznXbqrsLufY5SviwZw.Gs6m8vYoMzdMJBVwM_gMHuhBH7VOKxr3pB 8NJdXX2kmvphvsrvjHi2zkgAfsT41yn63i3Cqj78I2nrux_WQkWpX8.FOv_e zPuIxKMpY4psSsWiLsclDtUMZLpehA9sEaVktIkgMRhCZjxRSjRcHUMSeuLK TERlV0MQzr3HEdwRvxVasuxnHWp6g0cSJHPkBY8UVUOHwrRqeGOxWl_iDUlH yzOmozrj_B_jtMQ4ccqHmKWLkyzN0yfXbLkH3af5FHclJmrYENd515rjTZfR 3rhet7HwSyHzHjFfv4jyOOtzEbALG
X-Rocket-MIMEInfo 001.001, V2VsbCB0ZWxsIG1lIGhvdyBkbyB5b3UgdXNlIHRoaXMgc2NyaXB0IGluIGdlZGl0LCBhcmUgeW91IHVzaW5nIGl0IGFzIGEgcGx1Z2luID8gYXJlIHlvdSBwdXR0aW5nIHRoaXMgY29kZSBzb21ld2hlcmUgPyBJJ2xsIHRyeSB0byBkbyB0aGUgc2FtZSBvbiBteSBzaWRlIGFuZCB0cnkgdG8gdW5kZXJzdGFuZCBob3cgaXQgd29ya3MuCgoKCgoKCl9fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fCiBGcm9tOiBLdXJ0IEhhbnNlbiA8a3VydEB1Z3lsZGlnLmludmFsaWQ.ClRvOiBweXRob24tbGlzdEBweXQBMAEBAQE-
X-Mailer YahooMailWebService/0.8.130.494
References <50e97123$0$294$14726298@news.sunsite.dk> <mailman.161.1357477260.2939.python-list@python.org> <50e97e4c$0$294$14726298@news.sunsite.dk> <mailman.168.1357481051.2939.python-list@python.org> <50e9885e$0$294$14726298@news.sunsite.dk> <mailman.173.1357485172.2939.python-list@python.org> <50eafb00$0$287$14726298@news.sunsite.dk>
Date Tue, 8 Jan 2013 07:31:41 -0800 (PST)
From chaouche yacine <yacinechaouche@yahoo.com>
Subject Re: How to modify this script?
To Kurt Hansen <kurt@ugyldig.invalid>, "python-list@python.org" <python-list@python.org>
In-Reply-To <50eafb00$0$287$14726298@news.sunsite.dk>
MIME-Version 1.0
Content-Type multipart/alternative; boundary="-1546730761-700498275-1357659101=:20095"
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
Reply-To chaouche yacine <yacinechaouche@yahoo.com>
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.280.1357659111.2939.python-list@python.org> (permalink)
Lines 109
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1357659111 news.xs4all.nl 6982 [2001:888:2000:d::a6]:39177
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:36436

Show key headers only | View raw


[Multipart message — attachments visible in raw view] - view raw

Well tell me how do you use this script in gedit, are you using it as a plugin ? are you putting this code somewhere ? I'll try to do the same on my side and try to understand how it works.






________________________________
 From: Kurt Hansen <kurt@ugyldig.invalid>
To: python-list@python.org 
Sent: Monday, January 7, 2013 5:42 PM
Subject: Re: How to modify this script?
 
Den 06/01/13 16.12, chaouche yacine skrev:
> I'm not confident this would run on gedit. It works on a python
> interpreter if you have a file named data.txt in the same directory
> containing your sample data.
>
> It surely has to do with how gedit works then, because the "$" sign
> isn't used in python, this business should be a gedit convention. And
> sorry, I can't help on that, I'm not a user of gedit myself. Fortunately
> others have answered and I beleive one of the solutions worked for you.

It does not seem to be the case :-(

Thank you for trying to help.

> ------------------------------------------------------------------------
> *From:* Kurt Hansen <kurt@ugyldig.invalid>
> *To:* python-list@python.org
> *Sent:* Sunday, January 6, 2013 3:21 PM
> *Subject:* Re: How to modify this script?
>
> Den 06/01/13 15.01, chaouche yacine wrote:
>  > Well, I'm not answering your question since I am rewriting the script,
>  > because I prefer it this way :)
>  >
>  > def addline(line):
>  >      return "<tr>%s</tr>\n" % line
> [cut]
>
> I surpose I shall put your code between $< and >?
>
>  > printed
>  >
>  >  >>> <table>
>  > <tr><td colspan='3'>Price table</td></tr>
>  > <tr><td>1 </td><td> Green apple </td><td> $1</td></tr>
>  > <tr><td>5 </td><td> Green apples </td><td> $4</td></tr>
>  > <tr><td>10 </td><td> Green apples </td><td> $7</td></tr>
>  > </table>
>  >  >>>
>
> Aha, so you tested it yourself?
>
> When running this in Gedit on four lines of tab-separated text the
> output is:
>
> %s</tr>\n" % line
>
> def addcolumn(item,nb_columns):
>      if nb_columns != 3:
>          return "<td colspan='%s'>%s</td>" % (3 - nb_columns + 1, item)
>      return "<td>%s</td>" % item
>
> output = "<table>\n"
> for line in file("data.txt"):
>      items = line.strip().split("\t")
>      columns = ""
>      for item in items :
>          columns += addcolumn(item,len(items))
>      output  += addline(columns)
>
>
> output += "</table>"
> print output
>  >
> -- Venlig hilsen
> Kurt Hansen
> -- http://mail.python.org/mailman/listinfo/python-list
>
>


-- 
Venlig hilsen
Kurt Hansen
-- 
http://mail.python.org/mailman/listinfo/python-list

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