Path: csiph.com!usenet.pasdenom.info!gegeweb.org!newsfeed.kamp.net!newsfeed.kamp.net!newsfeed.freenet.ag!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.024 X-Spam-Evidence: '*H*': 0.95; '*S*': 0.00; 'append': 0.07; 'subject:file': 0.07; "'''": 0.09; 'template': 0.11; 'file,': 0.15; '.py': 0.16; 'f.read()': 0.16; 'received:your-server.de': 0.16; 'wrote:': 0.17; 'insert': 0.23; 'thus': 0.24; 'header:In- Reply-To:1': 0.25; 'header:User-Agent:1': 0.26; 'skip:" 20': 0.26; 'run': 0.28; '+0100,': 0.29; 'appending': 0.29; 'subject:end': 0.29; 'subject:some': 0.29; 'code': 0.31; 'url:python': 0.32; 'file': 0.32; 'print': 0.32; 'subject: .': 0.33; 'subject:data': 0.33; 'to:addr:python-list': 0.33; 'but': 0.36; 'url:org': 0.36; 'data.': 0.36; 'url:library': 0.36; 'does': 0.37; 'data': 0.37; 'subject:: ': 0.38; 'talk': 0.38; 'url:docs': 0.38; 'instead': 0.39; 'to:addr:python.org': 0.39; 'subject:-': 0.40; 'end': 0.40; 'dont': 0.64; '8bit%:100': 0.70; '2013': 0.84; 'url:show': 0.84 Content-Type: text/plain; charset=utf-8; format=flowed; delsp=yes To: python-list@python.org Subject: Re: Inserting-embedding some html data at the end of a .py file References: <7e0a8562-9a48-4f5a-804d-3751733288f0@googlegroups.com> <9af13b75-a7b0-45c9-a801-797989583cd5@googlegroups.com> Date: Tue, 05 Mar 2013 22:29:41 +0100 MIME-Version: 1.0 Content-Transfer-Encoding: Quoted-Printable From: "Michael Ross" In-Reply-To: <9af13b75-a7b0-45c9-a801-797989583cd5@googlegroups.com> User-Agent: Opera Mail/12.14 (Win32) X-Authenticated-Sender: gmx@ross.cx X-Virus-Scanned: Clear (ClamAV 0.97.6/16787/Tue Mar 5 18:39:27 2013) X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 60 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1362520352 news.xs4all.nl 6936 [2001:888:2000:d::a6]:42151 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:40572 On Tue, 05 Mar 2013 21:04:59 +0100, =CE=9D=CE=AF=CE=BA=CE=BF=CF=82 =CE=93= =CE=BA=CF=8133=CE=BA = wrote: > #open html template > if htmlpage.endswith('.html'): > f =3D open( "/home/nikos/public_html/" + htmlpage ) > > htmldata =3D f.read() > counter =3D '''
src=3D"/data/images/mail.png"> >
> > ''' % data[0] > > #render template = > template =3D htmldata + counter > print ( template ) > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > Yes the aboev code does work if we talk about appending html data to a= n = > already html file! > > But if the file is some_python.py file then i cannot just append the = > data. > Actually by appending i dont want to actually insert the data to the e= nd = > of the .py file, thus altering it but instead run the .py file and pri= nt = > the counter html data afterwards! subprocess.checkoutput() ? if htmlpage.endswith('.py'): htmldata=3Dsubprocess.check_output(...) counter=3D... template=3Dhtmldata+counter http://docs.python.org/2/library/subprocess.html?highlight=3Dcheck_outpu= t#subprocess.check_output
=CE=91=CF=81=CE=B9=CE=B8=CE=BC=CF= =8C=CF=82 =CE=95=CF=80=CE=B9=CF=83=CE=BA=CE=B5=CF=80=CF=84=CF=8E=CE=BD > = > %d