Monthly Archives: October 2011

Pretty printing a Python dictionary to HTML

Here’s a routine I wrote to pretty print a Python dict into an HTML table and though I’d share.

    def prettyTable(dictionary, cssClass=''):
        ''' pretty prints a dictionary into an HTML table(s) '''
        if isinstance(dictionary, str):
            return '<td>' + dictionary + '</td>'
        s = ['<table ']
        if cssClass != '':
            s.append('class="%s"' % (cssClass))
        for key, value in dictionary.iteritems():
            s.append('<tr>\n  <td valign="top"><strong>%s</strong></td>\n' % str(key))
            if isinstance(value, dict):
                if key == 'picture' or key == 'icon':
                    s.append('  <td valign="top"><img src="%s"></td>\n' % Page.prettyTable(value, cssClass))
                    s.append('  <td valign="top">%s</td>\n' % Page.prettyTable(value, cssClass))
            elif isinstance(value, list):
                for i in value:
                    s.append('<tr><td valign="top">%s</td></tr>\n' % Page.prettyTable(i, cssClass))
                if key == 'picture' or key == 'icon':
                    s.append('  <td valign="top"><img src="%s"></td>\n' % value)
                    s.append('  <td valign="top">%s</td>\n' % value)
s.append('</table>') return '\n'.join(s)

CNN's sad attempt to use Mike Arrington

While browsing tech news this morning I stumbled into Mike Arrington’s post about an interview he did with CNN. While I’m not always a fan of Arrington, though in this case, I completely accept his explaination of what happened in his interview with Solidad O’Brien. I’ve never read CNN for Tech news and rarely look at it otherwise though this incident will further cement that relationship (or lack thereof).

Btw, my prior and current CEO where Egyption and Persian respectively, both Entreprenuers.

Leaving Android for an iPhone 4S

I’m eligible for a device upgrade and as much as I’d like to stick with Android I can imagine myself feeling like James Kendrick in his piece After the iPhone 4s Android Just Feels Wrong. The Android experience for the last 18 mos. on my original Droid has been terrible to the point of laughable. This next round will be Apple iPhone 4S. Adios Android.

For the record I have the original Droid but I’ve also used an HTC EVO and my wife has an HTC Eris. We’re both switching to the iPhone.