Force anything to be a string.

Nathan Clegg nathan at islanddata.com
Mon Sep 20 12:54:47 EDT 1999


I use something like this to ensure my arguments are strings:

def stringify(x):
    if type(x) is type(1L):
        return '%ld' % (x,)
    else:
        return str(x)

I use a special case for longs because I don't normally want the 'L'
appended to my numbers.  End users don't like it :)



----------------------------------
Nathan Clegg
 nathan at islanddata.com






More information about the Python-list mailing list