newname = '-'.join( [ 'test.name' , 'converted_volume.ownerOxygenId' ] )
print newname
print u'best unicode safe string printing {} {}'.format( message , message2 ) # optionally use {0} {0} to repeat a variable
print 'tuple based printing: %s %s' % ( first , second )
newname = newname.strip() # remove whitespace (versus ltrim
shortname = '12345'
print 'shortname ' , shortname
print 'first [0]' , shortname[0]
print 'last [-1]' , shortname[-1]
emptystring = ''
try:
print 'last [-1] of an emptystring: ' , emptystring[-1]
except IndexError:
print 'Index error when using -1 for an empty string'
print 'first 3 only shortname[:3]' , shortname[:3]
print 'drop the first 3 shortname[3:]' , shortname[3:]
print 'drop the last 3 shortname[:-3]' , shortname[:-3]
print 'only the last 3 shortname[-3:]' , shortname[-3:]
import hashlib
print '%s hashlib.sha1' % hashlib.sha1( newname ).hexdigest()
print '%s hashlib.md5' % hashlib.md5( newname ).hexdigest()
import zlib
print '%s zlib.crc32' % str( zlib.crc32( newname ) & 0xffffffff ) # returns a long
print '%s zlib.adler32' % str( zlib.adler32( newname ) & 0xffffffff ) # returns a long