made hostname work with python 2.4
switched to iterator as per comments
Merge pull request #286 from bcoca/hostname_24_compatible

made hostname work with python 2.4