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


Groups > comp.lang.python > #37728 > unrolled thread

Formatting a column's value output

Started byFerrous Cranus <nikos.gr33k@gmail.com>
First post2013-01-26 09:51 -0800
Last post2013-01-26 13:07 -0800
Articles 13 on this page of 33 — 11 participants

Back to article view | Back to comp.lang.python


Contents

  Formatting a column's value output Ferrous Cranus <nikos.gr33k@gmail.com> - 2013-01-26 09:51 -0800
    Re: Formatting a column's value output Chris Angelico <rosuav@gmail.com> - 2013-01-27 05:04 +1100
      Re: Formatting a column's value output Ferrous Cranus <nikos.gr33k@gmail.com> - 2013-01-26 11:41 -0800
        Re: Formatting a column's value output Michael Torrie <torriem@gmail.com> - 2013-01-26 15:26 -0700
          Re: Formatting a column's value output Ferrous Cranus <nikos.gr33k@gmail.com> - 2013-01-27 01:04 -0800
            Re: Formatting a column's value output Chris Angelico <rosuav@gmail.com> - 2013-01-27 20:08 +1100
              Re: Formatting a column's value output Ferrous Cranus <nikos.gr33k@gmail.com> - 2013-01-27 01:16 -0800
                Re: Formatting a column's value output Chris Angelico <rosuav@gmail.com> - 2013-01-27 20:26 +1100
                  Re: Formatting a column's value output Κώστας Παπαδόπουλος <nikos.gr33k@gmail.com> - 2013-01-27 01:30 -0800
                  Re: Formatting a column's value output Κώστας Παπαδόπουλος <nikos.gr33k@gmail.com> - 2013-01-27 01:30 -0800
              Re: Formatting a column's value output Ferrous Cranus <nikos.gr33k@gmail.com> - 2013-01-27 01:16 -0800
            Re: Formatting a column's value output rurpy@yahoo.com - 2013-01-27 08:12 -0800
              Re: Formatting a column's value output Κώστας Παπαδόπουλος <nikos.gr33k@gmail.com> - 2013-01-27 10:05 -0800
                Re: Formatting a column's value output Joel Goldstick <joel.goldstick@gmail.com> - 2013-01-27 13:36 -0500
                  Re: Formatting a column's value output Κώστας Παπαδόπουλος <nikos.gr33k@gmail.com> - 2013-01-27 10:44 -0800
                  Re: Formatting a column's value output Κώστας Παπαδόπουλος <nikos.gr33k@gmail.com> - 2013-01-27 10:44 -0800
                    Re: Formatting a column's value output rurpy@yahoo.com - 2013-01-27 11:12 -0800
                      Re: Formatting a column's value output Κώστας Παπαδόπουλος <nikos.gr33k@gmail.com> - 2013-01-27 12:24 -0800
                        Re: Formatting a column's value output Mitya Sirenef <msirenef@lightbird.net> - 2013-01-27 15:50 -0500
                          Re: Formatting a column's value output rurpy@yahoo.com - 2013-01-27 14:27 -0800
                            Re: Formatting a column's value output Κώστας Παπαδόπουλος <nikos.gr33k@gmail.com> - 2013-01-28 01:47 -0800
                          Re: Formatting a column's value output Κώστας Παπαδόπουλος <nikos.gr33k@gmail.com> - 2013-01-28 01:44 -0800
                          Re: Formatting a column's value output Κώστας Παπαδόπουλος <nikos.gr33k@gmail.com> - 2013-01-28 01:44 -0800
              Re: Formatting a column's value output Virgil Stokes <vs@it.uu.se> - 2013-01-27 18:46 +0100
          Re: Formatting a column's value output Ferrous Cranus <nikos.gr33k@gmail.com> - 2013-01-27 01:04 -0800
      Re: Formatting a column's value output Ferrous Cranus <nikos.gr33k@gmail.com> - 2013-01-26 11:41 -0800
      Re: Formatting a column's value output Ferrous Cranus <nikos.gr33k@gmail.com> - 2013-01-26 13:07 -0800
        Re: Formatting a column's value output Chris Angelico <rosuav@gmail.com> - 2013-01-27 09:18 +1100
          Re: Formatting a column's value output alex23 <wuwei23@gmail.com> - 2013-01-26 15:29 -0800
            Re: Formatting a column's value output Chris Angelico <rosuav@gmail.com> - 2013-01-27 10:38 +1100
            Re: Formatting a column's value output Jason Friedman <jsf80238@gmail.com> - 2013-02-03 09:18 -0800
              Re: Formatting a column's value output Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-02-04 06:39 +0000
      Re: Formatting a column's value output Ferrous Cranus <nikos.gr33k@gmail.com> - 2013-01-26 13:07 -0800

Page 2 of 2 — ← Prev page 1 [2]


#37800

FromΚώστας Παπαδόπουλος <nikos.gr33k@gmail.com>
Date2013-01-28 01:47 -0800
Message-ID<687991f7-60a5-4066-85b0-01e265c78c53@googlegroups.com>
In reply to#37790
Τη Δευτέρα, 28 Ιανουαρίου 2013 12:27:12 π.μ. UTC+2, ο χρήστης ru...@yahoo.com έγραψε:
> On 01/27/2013 01:50 PM, Mitya Sirenef wrote:
> 
> > On 01/27/2013 03:24 PM, Κώστας Παπαδόπουλος wrote:
> 
> >> Τη Κυριακή, 27 Ιανουαρίου 2013  9:12:16 μ.μ. UTC+2, ο χρήστης ru...@yahoo.com έγραψε:
> 
> >  >> <python code>
> 
> >  >
> 
> >  > Yes indeed, there is no need to use a loop since i know the exact 
> 
> > number of items i'am expecting. Thanks you very much for clarifying this 
> 
> > to me:
> 
> >  > One last thing i want to ask you:
> 
> >  >
> 
> >  > ========================================
> 
> >  > try:
> 
> >  > cur.execute( '''SELECT host, userOS, browser, hits, lastvisit FROM 
> 
> > visitors
> 
> >  > WHERE counterID = (SELECT ID FROM counters WHERE URL = %s) ORDER BY 
> 
> > lastvisit DESC''', (htmlpage,) )
> 
> >  > except MySQLdb.Error, e:
> 
> >  > print ( "Query Error: ", sys.exc_info()[1].excepinfo()[2] )
> 
> >  > else:
> 
> >  > data = cur.fetchall()
> 
> >  >
> 
> >  > for host, useros, browser, hits, lastvisit in data:
> 
> >  > print ( "<tr>" )
> 
> >  >
> 
> >  > for item in host, useros, browser, hits, lastvisit.strftime('%A %e 
> 
> > %b, %H:%M').decode('cp1253').encode('utf8'):
> 
> >  > print ( "<td><center><b><font color=white> %s </td>" % item )
> 
> >  >
> 
> >  > sys.exit(0)
> 
> >  > =======================================
> 
> >  >
> 
> >  > That would be also written as:
> 
> >  >
> 
> >  > for row in data:
> 
> >  > print ("tr>")
> 
> >  > for item in row:
> 
> >  > print( "blah blah blah" )
> 
> >  >
> 
> >  > And that would make the code easier to read and more clear, but its 
> 
> > that 'lastvisit' column's value than needs formating,hence it makes me 
> 
> > use the above syntax.
> 
> >  >
> 
> >  > Is there any simpler way to write the above working code without the 
> 
> > need to specify all of the columns' names into the loop?
> 
> > 
> 
> > 
> 
> > You can write:
> 
> > 
> 
> >   for row in data:
> 
> >       print ("tr>")
> 
> >       row = list(row)
> 
> >       row[-1] = row[-1].strftime(...)
> 
> >       for item in row:
> 
> >           print( "blah blah blah" )
> 
> 
> 
> Or alternatively, 
> 
> 
> 
>     for row in data:
> 
>         print ("tr>")
> 
>         for item_num, item in enumerate (row):
> 
>             if item_num != len(row) - 1:
> 
>                 print( "blah blah blah" )
> 
>             else:
> 
>                 print( item.strftime(...) )
> 
> 
> 
> Or, being a little clearer, 
> 
> 
> 
>     LASTVISIT_POS = 4
> 
>     for row in data:
> 
>         print ("tr>")
> 
>         for item_num, item in enumerate (row):
> 
>             if item_num != LASTVISIT_POS:
> 
>                 print( "blah blah blah" )
> 
>             else:
> 
>                 print( item.strftime(...) )

Thank you very much, your alternatives are great but i think i'll use Mity'as solution, its more easy to me. Thank you very much!

[toc] | [prev] | [next] | [standalone]


#37799

FromΚώστας Παπαδόπουλος <nikos.gr33k@gmail.com>
Date2013-01-28 01:44 -0800
Message-ID<1adfcf88-7bd8-4699-adbf-ac8eece357d0@googlegroups.com>
In reply to#37789
Τη Κυριακή, 27 Ιανουαρίου 2013 10:50:33 μ.μ. UTC+2, ο χρήστης Mitya Sirenef έγραψε:
> On 01/27/2013 03:24 PM, οΏ½οΏ½οΏ½οΏ½οΏ½οΏ½ οΏ½οΏ½οΏ½οΏ½οΏ½οΏ½οΏ½οΏ½οΏ½οΏ½οΏ½οΏ½ wrote:
> 
> > οΏ½οΏ½ οΏ½οΏ½οΏ½οΏ½οΏ½οΏ½οΏ½, 27 οΏ½οΏ½οΏ½οΏ½οΏ½οΏ½οΏ½οΏ½οΏ½οΏ½ 2013  9:12:16 οΏ½.οΏ½. UTC+2, οΏ½ οΏ½οΏ½οΏ½οΏ½οΏ½οΏ½οΏ½ ru...@yahoo.com οΏ½οΏ½οΏ½οΏ½οΏ½οΏ½:
> 
>  >> <python code>
> 
>  >
> 
>  > Yes indeed, there is no need to use a loop since i know the exact 
> 
> number of items i'am expecting. Thanks you very much for clarifying this 
> 
> to me:
> 
>  > One last thing i want to ask you:
> 
>  >
> 
>  > ========================================
> 
>  > try:
> 
>  > cur.execute( '''SELECT host, userOS, browser, hits, lastvisit FROM 
> 
> visitors
> 
>  > WHERE counterID = (SELECT ID FROM counters WHERE URL = %s) ORDER BY 
> 
> lastvisit DESC''', (htmlpage,) )
> 
>  > except MySQLdb.Error, e:
> 
>  > print ( "Query Error: ", sys.exc_info()[1].excepinfo()[2] )
> 
>  > else:
> 
>  > data = cur.fetchall()
> 
>  >
> 
>  > for host, useros, browser, hits, lastvisit in data:
> 
>  > print ( "<tr>" )
> 
>  >
> 
>  > for item in host, useros, browser, hits, lastvisit.strftime('%A %e 
> 
> %b, %H:%M').decode('cp1253').encode('utf8'):
> 
>  > print ( "<td><center><b><font color=white> %s </td>" % item )
> 
>  >
> 
>  > sys.exit(0)
> 
>  > =======================================
> 
>  >
> 
>  > That would be also written as:
> 
>  >
> 
>  > for row in data:
> 
>  > print ("tr>")
> 
>  > for item in row:
> 
>  > print( "blah blah blah" )
> 
>  >
> 
>  > And that would make the code easier to read and more clear, but its 
> 
> that 'lastvisit' column's value than needs formating,hence it makes me 
> 
> use the above syntax.
> 
>  >
> 
>  > Is there any simpler way to write the above working code without the 
> 
> need to specify all of the columns' names into the loop?
> 
> 
> 
> 
> 
> You can write:
> 
> 
> 
>   for row in data:
> 
>       print ("tr>")
> 
>       row = list(row)
> 
>       row[-1] = row[-1].strftime(...)
> 
>       for item in row:
> 
>           print( "blah blah blah" )
> 
> 
> 
> 
> 
>   - mitya
> 
> 
> 
> 
> 
> -- 
> 
> Lark's Tongue Guide to Python: http://lightbird.net/larks/
> 
> 
> 
> The existence of any evil anywhere at any time absolutely ruins a total
> 
> optimism.  George Santayana


Thank you very much, your solution makes the code looks so much clearer!

[toc] | [prev] | [next] | [standalone]


#37801

FromΚώστας Παπαδόπουλος <nikos.gr33k@gmail.com>
Date2013-01-28 01:44 -0800
Message-ID<mailman.1127.1359366844.2939.python-list@python.org>
In reply to#37789
Τη Κυριακή, 27 Ιανουαρίου 2013 10:50:33 μ.μ. UTC+2, ο χρήστης Mitya Sirenef έγραψε:
> On 01/27/2013 03:24 PM, οΏ½οΏ½οΏ½οΏ½οΏ½οΏ½ οΏ½οΏ½οΏ½οΏ½οΏ½οΏ½οΏ½οΏ½οΏ½οΏ½οΏ½οΏ½ wrote:
> 
> > οΏ½οΏ½ οΏ½οΏ½οΏ½οΏ½οΏ½οΏ½οΏ½, 27 οΏ½οΏ½οΏ½οΏ½οΏ½οΏ½οΏ½οΏ½οΏ½οΏ½ 2013  9:12:16 οΏ½.οΏ½. UTC+2, οΏ½ οΏ½οΏ½οΏ½οΏ½οΏ½οΏ½οΏ½ ru...@yahoo.com οΏ½οΏ½οΏ½οΏ½οΏ½οΏ½:
> 
>  >> <python code>
> 
>  >
> 
>  > Yes indeed, there is no need to use a loop since i know the exact 
> 
> number of items i'am expecting. Thanks you very much for clarifying this 
> 
> to me:
> 
>  > One last thing i want to ask you:
> 
>  >
> 
>  > ========================================
> 
>  > try:
> 
>  > cur.execute( '''SELECT host, userOS, browser, hits, lastvisit FROM 
> 
> visitors
> 
>  > WHERE counterID = (SELECT ID FROM counters WHERE URL = %s) ORDER BY 
> 
> lastvisit DESC''', (htmlpage,) )
> 
>  > except MySQLdb.Error, e:
> 
>  > print ( "Query Error: ", sys.exc_info()[1].excepinfo()[2] )
> 
>  > else:
> 
>  > data = cur.fetchall()
> 
>  >
> 
>  > for host, useros, browser, hits, lastvisit in data:
> 
>  > print ( "<tr>" )
> 
>  >
> 
>  > for item in host, useros, browser, hits, lastvisit.strftime('%A %e 
> 
> %b, %H:%M').decode('cp1253').encode('utf8'):
> 
>  > print ( "<td><center><b><font color=white> %s </td>" % item )
> 
>  >
> 
>  > sys.exit(0)
> 
>  > =======================================
> 
>  >
> 
>  > That would be also written as:
> 
>  >
> 
>  > for row in data:
> 
>  > print ("tr>")
> 
>  > for item in row:
> 
>  > print( "blah blah blah" )
> 
>  >
> 
>  > And that would make the code easier to read and more clear, but its 
> 
> that 'lastvisit' column's value than needs formating,hence it makes me 
> 
> use the above syntax.
> 
>  >
> 
>  > Is there any simpler way to write the above working code without the 
> 
> need to specify all of the columns' names into the loop?
> 
> 
> 
> 
> 
> You can write:
> 
> 
> 
>   for row in data:
> 
>       print ("tr>")
> 
>       row = list(row)
> 
>       row[-1] = row[-1].strftime(...)
> 
>       for item in row:
> 
>           print( "blah blah blah" )
> 
> 
> 
> 
> 
>   - mitya
> 
> 
> 
> 
> 
> -- 
> 
> Lark's Tongue Guide to Python: http://lightbird.net/larks/
> 
> 
> 
> The existence of any evil anywhere at any time absolutely ruins a total
> 
> optimism.  George Santayana


Thank you very much, your solution makes the code looks so much clearer!

[toc] | [prev] | [next] | [standalone]


#37780

FromVirgil Stokes <vs@it.uu.se>
Date2013-01-27 18:46 +0100
Message-ID<mailman.1115.1359309930.2939.python-list@python.org>
In reply to#37774
On 27-Jan-2013 17:12, rurpy@yahoo.com wrote:
> On 01/27/2013 02:04 AM, Ferrous Cranus wrote:
>> [...]
>> 		data = cur.fetchall()
>> 		for row in data:
>> 			print ( "<tr>" )
>> 				
>> 			for item in row:
>> 				print( '''<td>  <a href='http://www.%s?show=log'>%s</a>  </td>''' % (item, item) )
>> [...]
>> Okey, so far BUT i want the url linking to happen only for the URL column's
>> value, and not for the hits column too. How do i apply the url link to the
>> URL column's value only?
> Ferrous,
>
> 'row' has two items (the url and the hit count) in it, right?
> So print each separately rather than in a loop:
>   
>      data = cur.fetchall()
>      for row in data:
> 	url = row[0]
> 	hits = row[1]
>          print ( "<tr>" )
>          print( "<td>  <a href='http://www.%s?show=log'>%s</a>  </td>: % (url, hits) )
It is nice to see some constructive feedback to Ferrous from the python-list. 
This will hopefully help to get Ferrous on the right track.

[toc] | [prev] | [next] | [standalone]


#37763

FromFerrous Cranus <nikos.gr33k@gmail.com>
Date2013-01-27 01:04 -0800
Message-ID<mailman.1107.1359277473.2939.python-list@python.org>
In reply to#37741
Τη Κυριακή, 27 Ιανουαρίου 2013 12:26:44 π.μ. UTC+2, ο χρήστης Michael Torrie έγραψε:

> A tuple is one method for passing variables into the string formatter.
> 
> So if you need to display something twice, just put in two "%s" in the
> 
> format string, and pass it the same variable twice.

Yes i know what a tuple is, iam just telling that the next code:
================================
	try:
		cur.execute( '''SELECT URL, hits FROM counters ORDER BY hits DESC''' )
	except MySQLdb.Error, e:
		print ( "Query Error: ", sys.exc_info()[1].excepinfo()[2] )
	else:
		data = cur.fetchall()
		
		for row in data:
			print ( "<tr>" )
				
			for item in row:
				print( '''<td>  <a href='http://www.%s?show=log'>%s</a>  </td>''' % (item, item) )
			
		sys.exit(0)
=================================
1. ruteruns a dataset
2. seperate each rows
3. itermate over the items of a row.

Okey, so far BUT i want the url linking to happen only for the URL column's value, and not for the hits column too. How do i apply the url link to the URL column's value only?

[toc] | [prev] | [next] | [standalone]


#37733

FromFerrous Cranus <nikos.gr33k@gmail.com>
Date2013-01-26 11:41 -0800
Message-ID<mailman.1087.1359229864.2939.python-list@python.org>
In reply to#37729
Τη Σάββατο, 26 Ιανουαρίου 2013 8:04:12 μ.μ. UTC+2, ο χρήστης Chris Angelico έγραψε:
> On Sun, Jan 27, 2013 at 4:51 AM, Ferrous Cranus <nikos.gr33k@gmail.com> wrote:
> 
> >                                 print ( "<td><b><font color=yellow> %s </td>" % item )
> 
> 
> 
> >
> 
> > In the aboce code wheb 'URL' is to be typed out be print i need it to be formatted as a link, so the viewer can click on it.
> 
> >
> 
> > Is this possible please?
> 
> 
> 
> Easy, just make a tuple of item,item and have two %s markers:
> 
> 
> 
> print( "<td><b><font color=yellow><a href='%s'>%s</a></td>" % (item, item) )
> 
> 
> 
> But you need to concern yourself with escaping. In fact, you already
> 
> needed to, just to produce it as text - but it's now even more
> 
> important. I strongly suggest you look into that.
 
I can use triple (''') quoting so i dont have to escape special characters.

But i didnt understand you suggestion about the tuple.

The dataset returns many lines and i need to transfor only the URL column....
Sorry i did not understood.

[toc] | [prev] | [next] | [standalone]


#37736

FromFerrous Cranus <nikos.gr33k@gmail.com>
Date2013-01-26 13:07 -0800
Message-ID<c9468b74-62a8-48f3-954a-7e2679a93f36@googlegroups.com>
In reply to#37729
Τη Σάββατο, 26 Ιανουαρίου 2013 8:04:12 μ.μ. UTC+2, ο χρήστης Chris Angelico έγραψε:
> On Sun, Jan 27, 2013 at 4:51 AM, Ferrous Cranus <nikos.gr33k@gmail.com> wrote:
> 
> >                                 print ( "<td><b><font color=yellow> %s </td>" % item )
> 
> 
> 
> >
> 
> > In the aboce code wheb 'URL' is to be typed out be print i need it to be formatted as a link, so the viewer can click on it.
> 
> >
> 
> > Is this possible please?
> 
> 
> 
> Easy, just make a tuple of item,item and have two %s markers:
> 
> 
> 
> print( "<td><b><font color=yellow><a href='%s'>%s</a></td>" % (item, item) )

That code works, but it creates links for both the URL and hits columns!
Only the URL must be linked not the hits column!

[toc] | [prev] | [next] | [standalone]


#37739

FromChris Angelico <rosuav@gmail.com>
Date2013-01-27 09:18 +1100
Message-ID<mailman.1089.1359238720.2939.python-list@python.org>
In reply to#37736
On Sun, Jan 27, 2013 at 8:07 AM, Ferrous Cranus <nikos.gr33k@gmail.com> wrote:
> That code works, but it creates links for both the URL and hits columns!
> Only the URL must be linked not the hits column!

1) Trim your quotes. I can't be bothered doing your trimming for you,
so I'm now under-quoting.

2) Quit using Google Groups, or manually fix its brain-dead double-spacing.

3) Look into Python's formatting options and see how to solve your own
problem. You'll probably want to use .format() rather than %.

4) Look into HTML entity escaping and do not publish anything to the
web until you understand why what you had before was dangerous.

ChrisA

[toc] | [prev] | [next] | [standalone]


#37744

Fromalex23 <wuwei23@gmail.com>
Date2013-01-26 15:29 -0800
Message-ID<03036f30-ec7a-4992-9494-4c3372a4e02e@ui9g2000pbc.googlegroups.com>
In reply to#37739
On Jan 27, 8:18 am, Chris Angelico <ros...@gmail.com> wrote:
> 1) Trim your quotes. I can't be bothered doing your trimming for you,
> so I'm now under-quoting.
>
> 2) Quit using Google Groups, or manually fix its brain-dead double-spacing.
>
> 3) Look into Python's formatting options and see how to solve your own
> problem. You'll probably want to use .format() rather than %.
>
> 4) Look into HTML entity escaping and do not publish anything to the
> web until you understand why what you had before was dangerous.

5) Please stop writing code for his _commercial web hosting service_
for free.

Notice that his next question is to ask you to modify your solution to
provide _exactly_ what he wants. He has no interest in learning Python.

[toc] | [prev] | [next] | [standalone]


#37747

FromChris Angelico <rosuav@gmail.com>
Date2013-01-27 10:38 +1100
Message-ID<mailman.1094.1359243520.2939.python-list@python.org>
In reply to#37744
On Sun, Jan 27, 2013 at 10:29 AM, alex23 <wuwei23@gmail.com> wrote:
> 5) Please stop writing code for his _commercial web hosting service_
> for free.

You mean, stop asking us to write &c.? With that edit, yes, I agree.

One of the difficulties on this list is that we don't have
two-dimensional people. Even our worst trolls have some redeeming
features. I can't just dismiss Ferrous out of hand...

ChrisA

[toc] | [prev] | [next] | [standalone]


#38108

FromJason Friedman <jsf80238@gmail.com>
Date2013-02-03 09:18 -0800
Message-ID<mailman.1315.1359911925.2939.python-list@python.org>
In reply to#37744
> One of the difficulties on this list is that we don't have
> two-dimensional people. Even our worst trolls have some redeeming
> features. I can't just dismiss Ferrous out of hand...

Indeed, and that is a "problem" with humanity in general.
It is proof that God (or the universe) has a sense of humor.
You and the others on this list who answer questions are earning a
_lot_ of good karma.

[toc] | [prev] | [next] | [standalone]


#38116

FromSteven D'Aprano <steve+comp.lang.python@pearwood.info>
Date2013-02-04 06:39 +0000
Message-ID<510f578e$0$29866$c3e8da3$5496439d@news.astraweb.com>
In reply to#38108
On Sun, 03 Feb 2013 09:18:42 -0800, Jason Friedman wrote:

>> One of the difficulties on this list is that we don't have
>> two-dimensional people. Even our worst trolls have some redeeming
>> features. I can't just dismiss Ferrous out of hand...
> 
> Indeed, and that is a "problem" with humanity in general. It is proof
> that God (or the universe) has a sense of humor.

If so, it's a vicious, nasty sense of humour. Imagine how simpler the 
world would be if there were no shades of grey, and we could easily, 
objectively and accurately divide people into two groups with no overlap:

- useful, nice, friendly people

- trolls and other low-lives


But no, even the worst scum have some redeeming features, and so we're 
left with difficult subjective judgements, and nobody can agree whether 
or not Person X should be pushed into a wood-chipper.



-- 
Steven

[toc] | [prev] | [next] | [standalone]


#37737

FromFerrous Cranus <nikos.gr33k@gmail.com>
Date2013-01-26 13:07 -0800
Message-ID<mailman.1088.1359234477.2939.python-list@python.org>
In reply to#37729
Τη Σάββατο, 26 Ιανουαρίου 2013 8:04:12 μ.μ. UTC+2, ο χρήστης Chris Angelico έγραψε:
> On Sun, Jan 27, 2013 at 4:51 AM, Ferrous Cranus <nikos.gr33k@gmail.com> wrote:
> 
> >                                 print ( "<td><b><font color=yellow> %s </td>" % item )
> 
> 
> 
> >
> 
> > In the aboce code wheb 'URL' is to be typed out be print i need it to be formatted as a link, so the viewer can click on it.
> 
> >
> 
> > Is this possible please?
> 
> 
> 
> Easy, just make a tuple of item,item and have two %s markers:
> 
> 
> 
> print( "<td><b><font color=yellow><a href='%s'>%s</a></td>" % (item, item) )

That code works, but it creates links for both the URL and hits columns!
Only the URL must be linked not the hits column!

[toc] | [prev] | [standalone]


Page 2 of 2 — ← Prev page 1 [2]

Back to top | Article view | comp.lang.python


csiph-web