Made get_ip() more pythonic