On 5 Αύγ, 11:55, Dennis Lee Bieber <wlfr...@ix.netcom.com> wrote: > On Wed, 4 Aug 2010 16:40:45 -0700 (PDT), Íßêïò > <nikos.the.gr...@gmail.com> declaimed the following in > gmane.comp.python.general: > > > for entry in row: > > entry = datetime.datetime.strftime( entry, '%d > > %b, %H:%M' ) #!!! > > this is wrong! > > print ( ''' <td> %s </td> ''' % entry ) > > > Apart from that i don't know how iam supposed to print it, because the > > date string is the 3rd string in every row of the dataset. > > As you state, it is the third item in each returned row... So why > are you trying to treat EVERY item in the row as a date?
Because when i try to prin the 3 items liek that print row[0], row[1], row[2] it gives me an error, so i dont knwo how to tell it how to print the 3rd item differently. > > Since MySQLdb appears to return datetime objects (my quick test is > showing datetime.date for dates in a test database) you should be > probably be using > > formatted_entry = entry.strftime("%d... %M") I tried that myself yesterday but look it fails to the following message /home/webville/public_html/cgi-bin/index.py 63 64 for entry in row: 65 formatted_entry = entry.strftime('%d %b, %H:%M') 66 print ( ''' <td> %s </td> ''' % entry ) 67 formatted_entry undefined, entry = '178-124-186.dynamic.cyta.gr', entry.strftime undefined AttributeError: 'str' object has no attribute 'strftime' args = ("'str' object has no attribute 'strftime'",) -- http://mail.python.org/mailman/listinfo/python-list