determining type

sp00fD sp00fD at yahoo.com
Wed Mar 22 12:44:06 EST 2000


Maybe I'm missing something, but how does this help if it's an integer
rather than a string?

In article <etdd7on3p8f.fsf at w20-575-109.mit.edu>,
Alex <alex at somewhere.round.here> wrote:
>
> > I'm trying to write a function to format the dictionary so that
when I
> > print it, rather than looking like {'foo' : 'bar', 'who' : 'what'},
it
> > looks like
> >
> > {
> > 'foo' : 'bar',
> > 'who' : 'what',
> > }
>
> import string
>
> def dictionary_str (d):
> output = ['{\n']
> for pair in d.items ():
> output.append ('%s : %s,\n' % tuple (map (repr, pair)))
> output.append ('}')
> return string.join (output, '')
>
> print dictionary_str ({'foo' : 'bar', 'who' : 'what'})
>
> Hope this helps.
> Alex.
>


Sent via Deja.com http://www.deja.com/
Before you buy.



More information about the Python-list mailing list