Try this: incport = '12.34.56.123:8080' export = incport.split(':')[0] Does that work for you? Alan G.