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


Groups > comp.lang.python > #40563

Re: Inserting-embedding some html data at the end of a .py file

Path csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!ecngs!feeder2.ecngs.de!newsfeed.freenet.ag!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <joel.goldstick@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.003
X-Spam-Evidence '*H*': 0.99; '*S*': 0.00; 'append': 0.07; 'subject:file': 0.07; 'python': 0.09; '&quot;': 0.09; "'''": 0.09; 'fails.': 0.09; 'inserted': 0.09; 'snippet': 0.09; 'cc:addr :python-list': 0.10; 'template': 0.11; '"a")': 0.16; '.py': 0.16; 'beautifully': 0.16; 'f.read()': 0.16; 'inserting': 0.16; 'opened.': 0.16; 'string': 0.17; 'wrote:': 0.17; 'tries': 0.17; 'changes': 0.20; 'email addr:gmail.com&gt;': 0.20; 'file.': 0.20; 'do.': 0.21; 'skip:= 20': 0.22; 'cc:2**0': 0.23; 'script': 0.24; 'cc:addr:python.org': 0.25; 'header:In-Reply-To:1': 0.25; 'displays': 0.27; 'message-id:@mail.gmail.com': 0.27; 'quoting': 0.29; 'subject:end': 0.29; 'subject:some': 0.29; 'url:mailman': 0.29; 'skip:& 10': 0.29; 'mode': 0.30; 'url:python': 0.32; 'file': 0.32; 'print': 0.32; 'url:listinfo': 0.32; 'skip:h 40': 0.33; 'subject: .': 0.33; 'subject:data': 0.33; 'skip:& 20': 0.33; 'received:google.com': 0.34; 'open': 0.35; 'pm,': 0.35; 'received:209.85': 0.35; 'but': 0.36; 'url:org': 0.36; 'received:209': 0.37; 'data': 0.37; 'subject:: ': 0.38; 'skip:o 20': 0.38; 'subject:-': 0.40; 'end': 0.40; 'url:mail': 0.40; '8bit%:50': 0.65; '8bit%:100': 0.70; '&lt;/td&gt;': 0.84; '&lt;img': 0.84; '2013': 0.84; '8bit%:65': 0.84; 'url:show': 0.84; 'joel': 0.91; 'write:': 0.91
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:x-received:in-reply-to:references:date:message-id :subject:from:to:cc:content-type; bh=wJdfBVrbHXicIk5Sp5fl5lInQvkBkOkMwe8lSUDYZG4=; b=Q0Yb006MbrRiP6aQxiOJ725t3cusbsuILOvm797PFIourLgurT7Hyh2z0K8TAWQzbw V+PjAYUTWCdP3g6zrl/eaf7DBuWjfQdV6TVCUgH4GJHb9C1ZBn2bOUmZOm6QKLJ3XgCp eVDeRJUwbBTVT09Ygb6GhL1WQPl6YrSPGzaPaoznbl55TyZPxXl4o9oHwRVNV7UH1Hus ixWFsOB+ck7TMLCoLkrH5cY+6RfZ+afBwfU1WghU7JYn51y7h8X7QoAsRqAtP5lZWttS JKtMogmRNM1fXAYo+4p8pZyY7H5bD6UZGR3bHMlGUutlWh/DvLkxtF1lCOOniUyXACwU wNbA==
MIME-Version 1.0
X-Received by 10.58.46.134 with SMTP id v6mr10383385vem.45.1362512040253; Tue, 05 Mar 2013 11:34:00 -0800 (PST)
In-Reply-To <cc677143-85d3-4ed2-9627-3872725ff1a3@googlegroups.com>
References <7e0a8562-9a48-4f5a-804d-3751733288f0@googlegroups.com> <fea70537-617e-4694-ace0-65568039e574@googlegroups.com> <mailman.2899.1362505528.2939.python-list@python.org> <14d3a13e-9d95-49b5-9d58-205021b79630@googlegroups.com> <mailman.2903.1362507510.2939.python-list@python.org> <cc677143-85d3-4ed2-9627-3872725ff1a3@googlegroups.com>
Date Tue, 5 Mar 2013 14:33:59 -0500
Subject Re: Inserting-embedding some html data at the end of a .py file
From Joel Goldstick <joel.goldstick@gmail.com>
To Νίκος Γκρ33κ <nikos.gr33k@gmail.com>
Content-Type multipart/alternative; boundary=089e0122a2e629646f04d7328e19
Cc "python-list@python.org" <python-list@python.org>
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.2906.1362512049.2939.python-list@python.org> (permalink)
Lines 194
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1362512049 news.xs4all.nl 6860 [2001:888:2000:d::a6]:52489
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:40563

Show key headers only | View raw


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

On Tue, Mar 5, 2013 at 1:53 PM, Νίκος Γκρ33κ <nikos.gr33k@gmail.com> wrote:

> Let's focus on just the following snipper please:
>
> f = open( some_python_file )
>
> htmldata = f.read()
> counter = ''' print( "
>                               <center><a href="mailto:support@superhost.gr">
> <img src="/data/images/mail.png"> </a>
>                               <center><table border=2 cellpadding=2
> bgcolor=black>
>                                           <td><font color=lime>Αριθμός
> Επισκεπτών</td>
>                                           <td><a href="
> http://superhost.gr/?show=stats"><font color=cyan> %d </td>
>                               " )
>                           ''' % data[0]
>
> #render template
> template = htmldata + counter
> print ( template )
> =============================
>
> What this snippet tries to accomplish is append the following string
>
> =========================================
>                 counter = ''' <center><a href="mailto:support@superhost.gr">
> <img src="/data/images/mail.png"> </a>
>                               <center><table border=2 cellpadding=2
> bgcolor=black>
>                                           <td><font color=lime>Αριθμός
> Επισκεπτών</td>
>                                           <td><a href="
> http://superhost.gr/?show=stats"><font color=cyan> %d </td>
>                           ''' % data[0
> =========================================
>
> at the end of the the python script file that it currently opened.
> I'am using the print statemnt inside the triple quoted string so to append
> that html data by inserting a print statemnt but although i have changes
> the type of quoting it still fails.
>
> If i try to append that html data to an .html file they are inserted
> beautifully but inside a .py file they dont.
>
> I just need to append that string after the end of a .py file. that's all
> i want to do.
> --
> http://mail.python.org/mailman/listinfo/python-list
>

print displays to the console.  To write to a file open file in 'append'
mode and write:

with open("test.py", "a") as myfile:
    myfile.write("appended text")



-- 
Joel Goldstick
http://joelgoldstick.com

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


Thread

Inserting-embedding some html data at the end of a .py file Νίκος Γκρ33κ <nikos.gr33k@gmail.com> - 2013-03-05 06:35 -0800
  Re: Inserting-embedding some html data at the end of a .py file Νίκος Γκρ33κ <nikos.gr33k@gmail.com> - 2013-03-05 09:11 -0800
    Re: Inserting-embedding some html data at the end of a .py file Mark Lawrence <breamoreboy@yahoo.co.uk> - 2013-03-05 17:19 +0000
    Re: Inserting-embedding some html data at the end of a .py file Joel Goldstick <joel.goldstick@gmail.com> - 2013-03-05 12:25 -0500
  Re: Inserting-embedding some html data at the end of a .py file Νίκος Γκρ33κ <nikos.gr33k@gmail.com> - 2013-03-05 09:39 -0800
    Re: Inserting-embedding some html data at the end of a .py file Joel Goldstick <joel.goldstick@gmail.com> - 2013-03-05 12:45 -0500
      Re: Inserting-embedding some html data at the end of a .py file Νίκος Γκρ33κ <nikos.gr33k@gmail.com> - 2013-03-05 09:49 -0800
        Re: Inserting-embedding some html data at the end of a .py file Dave Angel <davea@davea.name> - 2013-03-05 13:18 -0500
          Re: Inserting-embedding some html data at the end of a .py file Νίκος Γκρ33κ <nikos.gr33k@gmail.com> - 2013-03-05 10:53 -0800
            Re: Inserting-embedding some html data at the end of a .py file Joel Goldstick <joel.goldstick@gmail.com> - 2013-03-05 14:33 -0500
            Re: Inserting-embedding some html data at the end of a .py file Dave Angel <davea@davea.name> - 2013-03-05 14:48 -0500
          Re: Inserting-embedding some html data at the end of a .py file Νίκος Γκρ33κ <nikos.gr33k@gmail.com> - 2013-03-05 10:53 -0800
      Re: Inserting-embedding some html data at the end of a .py file Νίκος Γκρ33κ <nikos.gr33k@gmail.com> - 2013-03-05 09:49 -0800
    Re: Inserting-embedding some html data at the end of a .py file Mark Lawrence <breamoreboy@yahoo.co.uk> - 2013-03-05 17:53 +0000
    Re: Inserting-embedding some html data at the end of a .py file Roland Koebler <r.koebler@yahoo.de> - 2013-03-06 10:00 +0100
  Re: Inserting-embedding some html data at the end of a .py file Νίκος Γκρ33κ <nikos.gr33k@gmail.com> - 2013-03-05 12:04 -0800
    Re: Inserting-embedding some html data at the end of a .py file Dave Angel <d@davea.name> - 2013-03-05 16:02 -0500
      Re: Inserting-embedding some html data at the end of a .py file Νίκος Γκρ33κ <nikos.gr33k@gmail.com> - 2013-03-05 14:49 -0800
      Re: Inserting-embedding some html data at the end of a .py file Νίκος Γκρ33κ <nikos.gr33k@gmail.com> - 2013-03-05 14:49 -0800
    Re: Inserting-embedding some html data at the end of a .py file "Michael Ross" <gmx@ross.cx> - 2013-03-05 22:29 +0100
  Re: Inserting-embedding some html data at the end of a .py file Νίκος Γκρ33κ <nikos.gr33k@gmail.com> - 2013-03-05 14:47 -0800
    Re: Inserting-embedding some html data at the end of a .py file "Michael Ross" <gmx@ross.cx> - 2013-03-06 00:19 +0100
      Re: Inserting-embedding some html data at the end of a .py file Νίκος Γκρ33κ <nikos.gr33k@gmail.com> - 2013-03-05 15:39 -0800
        Re: Inserting-embedding some html data at the end of a .py file "Michael Ross" <gmx@ross.cx> - 2013-03-06 01:06 +0100
          Re: Inserting-embedding some html data at the end of a .py file Νίκος Γκρ33κ <nikos.gr33k@gmail.com> - 2013-03-05 22:12 -0800
          Re: Inserting-embedding some html data at the end of a .py file Νίκος Γκρ33κ <nikos.gr33k@gmail.com> - 2013-03-05 22:12 -0800
          Re: Inserting-embedding some html data at the end of a .py file Νίκος Γκρ33κ <nikos.gr33k@gmail.com> - 2013-03-05 23:48 -0800
          Re: Inserting-embedding some html data at the end of a .py file Νίκος Γκρ33κ <nikos.gr33k@gmail.com> - 2013-03-05 23:48 -0800
          Re: Inserting-embedding some html data at the end of a .py file Νίκος Γκρ33κ <nikos.gr33k@gmail.com> - 2013-03-06 15:18 -0800
            Re: Inserting-embedding some html data at the end of a .py file "Michael Ross" <gmx@ross.cx> - 2013-03-07 01:25 +0100
              Re: Inserting-embedding some html data at the end of a .py file Νίκος Γκρ33κ <nikos.gr33k@gmail.com> - 2013-03-06 22:35 -0800
                Re: Inserting-embedding some html data at the end of a .py file Roland Koebler <r.koebler@yahoo.de> - 2013-03-07 09:58 +0100
                Re: Inserting-embedding some html data at the end of a .py file Νίκος Γκρ33κ <nikos.gr33k@gmail.com> - 2013-03-07 01:05 -0800
                Re: Inserting-embedding some html data at the end of a .py file Lele Gaifax <lele@metapensiero.it> - 2013-03-07 10:22 +0100
                Re: Inserting-embedding some html data at the end of a .py file Νίκος Γκρ33κ <nikos.gr33k@gmail.com> - 2013-03-07 01:28 -0800
                Re: Inserting-embedding some html data at the end of a .py file Lele Gaifax <lele@metapensiero.it> - 2013-03-07 10:50 +0100
                Re: Inserting-embedding some html data at the end of a .py file Νίκος Γκρ33κ <nikos.gr33k@gmail.com> - 2013-03-07 01:55 -0800
                Re: Inserting-embedding some html data at the end of a .py file Νίκος Γκρ33κ <nikos.gr33k@gmail.com> - 2013-03-07 01:55 -0800
                Re: Inserting-embedding some html data at the end of a .py file Chris Angelico <rosuav@gmail.com> - 2013-03-07 21:19 +1100
                Re: Inserting-embedding some html data at the end of a .py file Νίκος Γκρ33κ <nikos.gr33k@gmail.com> - 2013-03-07 02:34 -0800
                Re: Inserting-embedding some html data at the end of a .py file Νίκος Γκρ33κ <nikos.gr33k@gmail.com> - 2013-03-07 02:34 -0800
                Re: Inserting-embedding some html data at the end of a .py file Νίκος Γκρ33κ <nikos.gr33k@gmail.com> - 2013-03-07 03:51 -0800
                Re: Inserting-embedding some html data at the end of a .py file Νίκος Γκρ33κ <nikos.gr33k@gmail.com> - 2013-03-07 03:51 -0800
                Re: Inserting-embedding some html data at the end of a .py file Νίκος Γκρ33κ <nikos.gr33k@gmail.com> - 2013-03-07 01:28 -0800
                Re: Inserting-embedding some html data at the end of a .py file Νίκος Γκρ33κ <nikos.gr33k@gmail.com> - 2013-03-07 02:09 -0800
                Re: Inserting-embedding some html data at the end of a .py file Joel Goldstick <joel.goldstick@gmail.com> - 2013-03-07 05:28 -0500
                Re: Inserting-embedding some html data at the end of a .py file Νίκος Γκρ33κ <nikos.gr33k@gmail.com> - 2013-03-07 04:06 -0800
                Re: Inserting-embedding some html data at the end of a .py file Chris Angelico <rosuav@gmail.com> - 2013-03-07 23:17 +1100
                Re: Inserting-embedding some html data at the end of a .py file Νίκος Γκρ33κ <nikos.gr33k@gmail.com> - 2013-03-07 04:06 -0800
                Re: Inserting-embedding some html data at the end of a .py file Νίκος Γκρ33κ <nikos.gr33k@gmail.com> - 2013-03-07 02:09 -0800
                Re: Inserting-embedding some html data at the end of a .py file Νίκος Γκρ33κ <nikos.gr33k@gmail.com> - 2013-03-07 01:05 -0800
              Re: Inserting-embedding some html data at the end of a .py file Νίκος Γκρ33κ <nikos.gr33k@gmail.com> - 2013-03-06 22:35 -0800
              Re: Inserting-embedding some html data at the end of a .py file Νίκος Γκρ33κ <nikos.gr33k@gmail.com> - 2013-03-06 22:42 -0800
              Re: Inserting-embedding some html data at the end of a .py file Νίκος Γκρ33κ <nikos.gr33k@gmail.com> - 2013-03-06 22:42 -0800
          Re: Inserting-embedding some html data at the end of a .py file Νίκος Γκρ33κ <nikos.gr33k@gmail.com> - 2013-03-06 15:18 -0800
      Re: Inserting-embedding some html data at the end of a .py file Νίκος Γκρ33κ <nikos.gr33k@gmail.com> - 2013-03-05 15:39 -0800

csiph-web