made hostname work with python 2.4

should fix #9413
Note: Python2.4 has iterators and generator expressions.  It would be good if we got into the habit of using iterators instead of lists and generator expressions instead of list comprehensions when the list is unnecessary overhead.

This would then look like:
```
lines = (x.strip() for x in f)
```